com.planet_ink.coffee_mud.Libraries
Class CoffeeTime

java.lang.Object
  extended by com.planet_ink.coffee_mud.Libraries.StdLibrary
      extended by com.planet_ink.coffee_mud.Libraries.CoffeeTime
All Implemented Interfaces:
CMObject, Tickable, CMLibrary, TimeManager, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class CoffeeTime
extends StdLibrary
implements TimeManager


Field Summary
protected  TimeClock globalClock
           
 
Fields inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
isDebugging, name, serviceClient, tickStatus
 
Fields inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.TimeManager
MILI_DAY, MILI_HOUR, MILI_MINUTE, MILI_MONTH, MILI_SECOND, MILI_WEEK, MILI_YEAR, MONTHS, SHORTMONTHS
 
Fields inherited from interface com.planet_ink.coffee_mud.core.interfaces.Tickable
STATUS_AFFECT, STATUS_ALIVE, STATUS_BEHAVIOR, STATUS_CLASS, STATUS_DEAD, STATUS_END, STATUS_FIGHT, STATUS_MISC, STATUS_MISC2, STATUS_MISC3, STATUS_MISC4, STATUS_MISC5, STATUS_MISC6, STATUS_MISC7, STATUS_NOT, STATUS_OTHER, STATUS_RACE, STATUS_REBIRTH, STATUS_SCRIPT, STATUS_START, STATUS_WEATHER, TICKID_AREA, TICKID_BEAMWEAPON, TICKID_CLAN, TICKID_CLANITEM, TICKID_DEADBODY_DECAY, TICKID_ELECTRONICS, TICKID_EMAIL, TICKID_EXIT_BEHAVIOR, TICKID_EXIT_REOPEN, TICKID_ITEM_BEHAVIOR, TICKID_ITEM_BOUNCEBACK, TICKID_LIGHT_FLICKERS, TICKID_LIVEAUCTION, TICKID_LONGERMASK, TICKID_MISCELLANEOUS, TICKID_MOB, TICKID_PROPERTY_SPECIAL, TICKID_QUEST, TICKID_READYTOSTOP, TICKID_ROOM_BEHAVIOR, TICKID_ROOM_ITEM_REJUV, TICKID_SOLITARYMASK, TICKID_SPECIALCOMBAT, TICKID_SPECIALMANEUVER, TICKID_SPELL_AFFECT, TICKID_SUPPORT, TICKID_TIMEAUCTION, TICKID_TRAP_DESTRUCTION, TICKID_TRAP_RESET
 
Constructor Summary
CoffeeTime()
           
 
Method Summary
 java.lang.String convertHour(java.lang.String hours24)
          Returns the regular Hours given the hours in the international format (military time) Usage: ConvertHour(GetIn(req, "ENDHR"))
 java.lang.String date2AMPMString(java.util.Calendar C)
           
 java.lang.String date2AMPMString(long time)
          Returns the Minutes portion of a given Time Usage: String ST_AMPM=date2AMPMString(time);
 java.lang.String date2APTimeString(long time)
          Return the time in HH:MM AP format.
 java.lang.String date2BestShortEllapsedTime(long t)
          Picks the single best representation of the given ellapsed time, from seconds to minutes to hours to days, and returns the correct amount along with the single letter suffix
 java.lang.String date2BriefString(long time)
          Returns time in HH:MMap format, unless the day is other than today, in which case it prepends yy/m/d.
 java.lang.String date2Date2String(long time)
          Converts a given date into a string of form: MM/DD/YY Usage: date2Date2String(time)
 java.lang.String date2DateString(long time)
          Converts a given date into a string of form: MM/DD/YYYY Usage: date2DateString(time)
 java.lang.String date2DayOfMonthString(long time)
          Returns the DD portion of a given date Usage: String ENDDD=date2DayOfMonthString();
 java.lang.String date2EllapsedTime(long time, java.util.concurrent.TimeUnit minUnit, boolean shortest)
          Converts a given number of milliseconds, into a number of rl years, months, days, hours, minutes, and seconds.
 java.lang.String date2HRString(java.util.Calendar C)
           
 java.lang.String date2HRString(long time)
          Returns the Hours portion of a given Time Usage: String ENDHR=date2HRString();
 java.lang.String date2MINString(java.util.Calendar C)
           
 java.lang.String date2MINString(long time)
          Returns the Minutes portion of a given Time Usage: String ENDMIN=date2MINString();
 java.lang.String date2MonthDateString(long time, boolean shortName)
          Returns the month/day for a given date Usage: String ENDMM=date2MonthDateString();
 java.lang.String date2MonthString(long time, boolean shortName)
          Returns the month for a given date Usage: String ENDMM=date2MonthString(time,true);
 java.lang.String date2SecondsString(long time)
          Converts a given date into a string of form: MM/DD/YYYY HH:MM AP Usage: date2SecondsString(time)
 java.lang.String date2SmartEllapsedTime(long time, boolean shortest)
          Converts a given number of milliseconds, into a number of rl years, months, days, hours, minutes, and seconds.
 java.lang.String date2String(java.util.Calendar C)
          Converts a given date into a string of form: MM/DD/YYYY HH:MM AP Usage: date2String()
 java.lang.String date2String(long time)
          Converts a given date into a string of form: MM/DD/YYYY HH:MM AP Usage: date2String(time)
 java.lang.String date2YYYYString(long time)
          Returns the YYYY portion of a given date Returns the DD portion of a given date Usage: String ENDYYYY=date2YYYYString();
 java.lang.String date2ZoneString(long time)
          Returns the time zone of the server Usage: MEETZN = T2ZoneString();
 java.lang.String getAMPM(java.lang.String TheHour)
          Returns the AMPM stamp given the international Hours portion the Time Usage: getAMPM(GetIn(req, "ENDHR"))
 java.lang.String getMonthName(int number, boolean giveShort)
          Return the name of the month, given a number Usage: String Mnth=getMonthName(m,GiveShort).charStats();
 java.lang.String getTheIntZoneID(int theRawOffset)
          Get the zone id given the timezone string Usage: GetTheZoneID(MeetTZ.getRawOffset())+"\n";
 java.lang.String getTheTimeZone(java.lang.String theID)
          Returns the time zone of the given ID Usage: MEETZN = GetTheTimeZone(ID);
 TimeClock globalClock()
          Returns the mud wide global time clock object as defined by the coffeemud.ini file.
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 boolean isTickExpression(java.lang.String val)
          Parses whether a tick expression, or an expression ending with the word minutes, hours, seconds, days, mudhours, muddays, mudweeks, mudmonths, or mudyears
 boolean isValidDateString(java.lang.String dateTimeStr)
          Returns whether the given string would parse to a valid date.
 TimeClock localClock(Physical P)
          Returns the most local clock for the given object.
 java.lang.String month2MM(java.lang.String monthName)
          Returns the numeric representation of the month Usage: month2MM("January");
 int parseTickExpression(java.lang.String val)
          Parses either a tick expression, or an expression ending with the word minutes, hours, seconds, days, mudhours, muddays, mudweeks, mudmonths, or mudyears
 java.lang.String smtpDateFormat(long time)
          format the date for an smtp message Usage: smtpDateFormat(98374987234)
 java.util.Calendar string2Date(java.lang.String dateTimeStr)
          Converts a string of some form into a Calendar object.
 long string2Millis(java.lang.String dateTimeStr)
          Converts a string of some form into a Calendar object.
 java.lang.String twoDigits(long num)
          Converts a number to two digits.
 
Methods inherited from class com.planet_ink.coffee_mud.Libraries.StdLibrary
activate, checkDatabase, compareTo, copyOf, getServiceClient, getTickStatus, initializeClass, L, name, newInstance, propertiesLoaded, setThreadStatus, shutdown, tick
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.planet_ink.coffee_mud.Libraries.interfaces.CMLibrary
activate, getServiceClient, L, propertiesLoaded, shutdown
 
Methods inherited from interface com.planet_ink.coffee_mud.core.interfaces.CMObject
copyOf, initializeClass, name, newInstance
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

globalClock

protected TimeClock globalClock
Constructor Detail

CoffeeTime

public CoffeeTime()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, Tech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Overrides:
ID in class StdLibrary
Returns:
the name of this class

month2MM

public java.lang.String month2MM(java.lang.String monthName)
Description copied from interface: TimeManager
Returns the numeric representation of the month Usage: month2MM("January");

Specified by:
month2MM in interface TimeManager
Parameters:
monthName - The month name
Returns:
String The number of the month as a string

getMonthName

public java.lang.String getMonthName(int number,
                                     boolean giveShort)
Description copied from interface: TimeManager
Return the name of the month, given a number Usage: String Mnth=getMonthName(m,GiveShort).charStats();

Specified by:
getMonthName in interface TimeManager
Parameters:
number - Month number to convert
giveShort - Give abbreviation if true
Returns:
String Month name

string2Millis

public long string2Millis(java.lang.String dateTimeStr)
Description copied from interface: TimeManager
Converts a string of some form into a Calendar object. Usage: string2Millis(GetRes(Results,"StartDateTime"));

Specified by:
string2Millis in interface TimeManager
Parameters:
dateTimeStr - The string to retrieve from
Returns:
Calendar Calendar object

string2Date

public java.util.Calendar string2Date(java.lang.String dateTimeStr)
Description copied from interface: TimeManager
Converts a string of some form into a Calendar object. Usage: Calendar.string2Date(GetRes(Results,"StartDateTime"));

Specified by:
string2Date in interface TimeManager
Parameters:
dateTimeStr - The string to retrieve from
Returns:
Calendar Calendar object

isValidDateString

public boolean isValidDateString(java.lang.String dateTimeStr)
Description copied from interface: TimeManager
Returns whether the given string would parse to a valid date. If true is returned, the change of getting a valid date from string2Date is much higher.

Specified by:
isValidDateString in interface TimeManager
Parameters:
dateTimeStr - the strong to parse
Returns:
true if its possibly valid, false definitely not

convertHour

public java.lang.String convertHour(java.lang.String hours24)
Description copied from interface: TimeManager
Returns the regular Hours given the hours in the international format (military time) Usage: ConvertHour(GetIn(req, "ENDHR"))

Specified by:
convertHour in interface TimeManager
Parameters:
hours24 - Hours in military format
Returns:
String Hours in regular format

getAMPM

public java.lang.String getAMPM(java.lang.String TheHour)
Description copied from interface: TimeManager
Returns the AMPM stamp given the international Hours portion the Time Usage: getAMPM(GetIn(req, "ENDHR"))

Specified by:
getAMPM in interface TimeManager
Parameters:
TheHour - Hours in military format
Returns:
String AM or PM stamp

getTheIntZoneID

public java.lang.String getTheIntZoneID(int theRawOffset)
Description copied from interface: TimeManager
Get the zone id given the timezone string Usage: GetTheZoneID(MeetTZ.getRawOffset())+"\n";

Specified by:
getTheIntZoneID in interface TimeManager
Parameters:
theRawOffset - The time zone's raw offset to convert
Returns:
String The time zone ID

getTheTimeZone

public java.lang.String getTheTimeZone(java.lang.String theID)
Description copied from interface: TimeManager
Returns the time zone of the given ID Usage: MEETZN = GetTheTimeZone(ID);

Specified by:
getTheTimeZone in interface TimeManager
Parameters:
theID - The ID of the abbreviated time zone.
Returns:
String The time zone name

date2MonthString

public java.lang.String date2MonthString(long time,
                                         boolean shortName)
Description copied from interface: TimeManager
Returns the month for a given date Usage: String ENDMM=date2MonthString(time,true);

Specified by:
date2MonthString in interface TimeManager
Parameters:
time - The time in miliseconds
shortName - true to use shortened months
Returns:
String The month name

date2MonthDateString

public java.lang.String date2MonthDateString(long time,
                                             boolean shortName)
Description copied from interface: TimeManager
Returns the month/day for a given date Usage: String ENDMM=date2MonthDateString();

Specified by:
date2MonthDateString in interface TimeManager
Parameters:
time - The time in miliseconds
shortName - true to use shortened months
Returns:
String the month/day name

date2DayOfMonthString

public java.lang.String date2DayOfMonthString(long time)
Description copied from interface: TimeManager
Returns the DD portion of a given date Usage: String ENDDD=date2DayOfMonthString();

Specified by:
date2DayOfMonthString in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String The day

twoDigits

public java.lang.String twoDigits(long num)
Description copied from interface: TimeManager
Converts a number to two digits.

Specified by:
twoDigits in interface TimeManager
Parameters:
num - the number
Returns:
the number as two digits

date2YYYYString

public java.lang.String date2YYYYString(long time)
Description copied from interface: TimeManager
Returns the YYYY portion of a given date Returns the DD portion of a given date Usage: String ENDYYYY=date2YYYYString();

Specified by:
date2YYYYString in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String The year

date2HRString

public java.lang.String date2HRString(long time)
Description copied from interface: TimeManager
Returns the Hours portion of a given Time Usage: String ENDHR=date2HRString();

Specified by:
date2HRString in interface TimeManager
Parameters:
time - time used
Returns:
String The hour

date2MINString

public java.lang.String date2MINString(long time)
Description copied from interface: TimeManager
Returns the Minutes portion of a given Time Usage: String ENDMIN=date2MINString();

Specified by:
date2MINString in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String The minutes

date2HRString

public java.lang.String date2HRString(java.util.Calendar C)

date2MINString

public java.lang.String date2MINString(java.util.Calendar C)

date2ZoneString

public java.lang.String date2ZoneString(long time)
Description copied from interface: TimeManager
Returns the time zone of the server Usage: MEETZN = T2ZoneString();

Specified by:
date2ZoneString in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String The time zone

date2AMPMString

public java.lang.String date2AMPMString(long time)
Description copied from interface: TimeManager
Returns the Minutes portion of a given Time Usage: String ST_AMPM=date2AMPMString(time);

Specified by:
date2AMPMString in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String AM or PM stamp

date2AMPMString

public java.lang.String date2AMPMString(java.util.Calendar C)

date2APTimeString

public java.lang.String date2APTimeString(long time)
Description copied from interface: TimeManager
Return the time in HH:MM AP format.

Specified by:
date2APTimeString in interface TimeManager
Parameters:
time - the time in millis
Returns:
the time in format

date2BriefString

public java.lang.String date2BriefString(long time)
Description copied from interface: TimeManager
Returns time in HH:MMap format, unless the day is other than today, in which case it prepends yy/m/d. Usage: String ENDMM=date2BriefString(time,true);

Specified by:
date2BriefString in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String The date string

date2String

public java.lang.String date2String(java.util.Calendar C)
Description copied from interface: TimeManager
Converts a given date into a string of form: MM/DD/YYYY HH:MM AP Usage: date2String()

Specified by:
date2String in interface TimeManager
Parameters:
C - The time in calendar
Returns:
String Formatted date/time

date2String

public java.lang.String date2String(long time)
Description copied from interface: TimeManager
Converts a given date into a string of form: MM/DD/YYYY HH:MM AP Usage: date2String(time)

Specified by:
date2String in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String Formatted date/time

date2EllapsedTime

public java.lang.String date2EllapsedTime(long time,
                                          java.util.concurrent.TimeUnit minUnit,
                                          boolean shortest)
Description copied from interface: TimeManager
Converts a given number of milliseconds, into a number of rl years, months, days, hours, minutes, and seconds. If in short form, returns y, m, d, h, m, and s. Usage: date2EllapsedTime(time)

Specified by:
date2EllapsedTime in interface TimeManager
Parameters:
time - The time in miliseconds
minUnit - The smallest unit to round down to
shortest - true for short form, false otherwise
Returns:
String Formatted ellapsed time

date2BestShortEllapsedTime

public java.lang.String date2BestShortEllapsedTime(long t)
Description copied from interface: TimeManager
Picks the single best representation of the given ellapsed time, from seconds to minutes to hours to days, and returns the correct amount along with the single letter suffix

Specified by:
date2BestShortEllapsedTime in interface TimeManager
Parameters:
t - time in milliseconds
Returns:
ellapsed time approximation.

date2SmartEllapsedTime

public java.lang.String date2SmartEllapsedTime(long time,
                                               boolean shortest)
Description copied from interface: TimeManager
Converts a given number of milliseconds, into a number of rl years, months, days, hours, minutes, and seconds. If in short form, returns y, m, d, h, m, and s. This method will automatically determine the smallest reasonable unit of time to show. Usage: date2SmartEllapsedTime(time)

Specified by:
date2SmartEllapsedTime in interface TimeManager
Parameters:
time - The time in miliseconds
shortest - true for short form, false otherwise
Returns:
String Formatted ellapsed time

date2SecondsString

public java.lang.String date2SecondsString(long time)
Description copied from interface: TimeManager
Converts a given date into a string of form: MM/DD/YYYY HH:MM AP Usage: date2SecondsString(time)

Specified by:
date2SecondsString in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String Formatted date/time

date2DateString

public java.lang.String date2DateString(long time)
Description copied from interface: TimeManager
Converts a given date into a string of form: MM/DD/YYYY Usage: date2DateString(time)

Specified by:
date2DateString in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String Formatted date

date2Date2String

public java.lang.String date2Date2String(long time)
Description copied from interface: TimeManager
Converts a given date into a string of form: MM/DD/YY Usage: date2Date2String(time)

Specified by:
date2Date2String in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String Formatted date

smtpDateFormat

public java.lang.String smtpDateFormat(long time)
Description copied from interface: TimeManager
format the date for an smtp message Usage: smtpDateFormat(98374987234)

Specified by:
smtpDateFormat in interface TimeManager
Parameters:
time - The time in miliseconds
Returns:
String The minutes

globalClock

public TimeClock globalClock()
Description copied from interface: TimeManager
Returns the mud wide global time clock object as defined by the coffeemud.ini file.

Specified by:
globalClock in interface TimeManager
Returns:
the global clock
See Also:
TimeClock

isTickExpression

public boolean isTickExpression(java.lang.String val)
Description copied from interface: TimeManager
Parses whether a tick expression, or an expression ending with the word minutes, hours, seconds, days, mudhours, muddays, mudweeks, mudmonths, or mudyears

Specified by:
isTickExpression in interface TimeManager
Parameters:
val - the expression
Returns:
whether a number of ticks is represented by the string

parseTickExpression

public int parseTickExpression(java.lang.String val)
Description copied from interface: TimeManager
Parses either a tick expression, or an expression ending with the word minutes, hours, seconds, days, mudhours, muddays, mudweeks, mudmonths, or mudyears

Specified by:
parseTickExpression in interface TimeManager
Parameters:
val - the expression
Returns:
the number of ticks represented by the string

localClock

public TimeClock localClock(Physical P)
Description copied from interface: TimeManager
Returns the most local clock for the given object.

Specified by:
localClock in interface TimeManager
Parameters:
P - an item, room, mob, whatever.
Returns:
the local clock
See Also:
TimeClock