From the NannyMUD documentation

LAST CHANGE

2002-10-03

NAME

        timed - NannyMUD local time daemon.

DESCRIPTION

	The local NannyMUD time.

	The idea is simply to have the 'normal' day converted in to
	small 'Nannydays' each of these days 19 real hours, with 2
	hours of night.

	+ A NannyMinute is 23 seconds.
	+ A NannyHour is 58 NannyMinutes.
	+ A NannyDay is 19 NannyHours.
	+ A Nannyweek is 7 Nannydays.
	+ A Nannymonth is 21 Nannydays. This is 3 Nannyweeks.
	+ A Nanny Year is 13 Nannymonths.
	+ A Mooncycle is completed in 8 Nannydays.
	+ Years have their own names, wich are repeated in cycles 
	  of 17 years.
	+ The start of the Nannytime is April 25, 1990.

FUNCTIONS

QUERY FUNCTIONS

        query_season
        query_second
        query_minute
        query_hour
        query_day_part
        query_daytime
        query_night
        query_weekday
        query_month
        query_year
        query_moon_phase
        query_moon_position
        query_moon_cycle
        query_moon
        query_sun_position

OTHER FUNCTIONS

	_name_of_year
	_name_of_month
	_name_of_day
	_year
	_month
	_mday
	_weekday
	nanny_time2
    	_ctime
	_time_of_day
	_part_of_day
	dtime
	_dtime
	_time
	nanny_time
	_phase
        ctime_to_time

NOTE

	So, why do we bother with this?
	Well, it would add a new dimension to the game, and thus make it
	more fun to play it. The idea is to let certain powers be better
	at certain times, a classic example is of course were-creatures.

        See the SIMPLE QUERY FUNCTIONS for easy interface, especially when
        using time_room.c

FUNCTION


NAME

        _name_of_year - _name_of_year - Give the name of a year.

SYNTAX

string _name_of_year(int year)

DESCRIPTION

	Year names are cyclic, and repeated every 17 years. This function
	returns the correct name for every year in the range [0..MAX_INT].
	The following names are used:

	  The Year of Creation
          The Year of the Daemon
          The Year of the Wind
          The Year of the Dragon
          The Year of the Giants
          The Year of the Elves
          The Year of Magic
          The Year of Humans
          The Year of the Golden Age
          The Year of Sacrilege
          The Year of Darkness
          The Year of Blood
          The Year of Sacrifice
          The Year of Purification
          The Year of Light
          The Year of Balance
          The Year of Law

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_name_of_year(TD->_year(TD->_time())));

FUNCTION


NAME

        _name_of_month - 

SYNTAX

string _name_of_month(int month)

DESCRIPTION

	Returns the name of the month. The following names are used:

		The Month of Darkness
		The Month of Truth
		The Month of Wind
		The Month of Water
		The Month of Spirit
		The Month of Fertility
		The Month of Plant
		The Month of Earth
		The Month of Harmony
		The Month of Fire
		The Month of Illusion
		The Month of Law
		The Month of Demons

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_name_of_month(TD->_month(TD->_time())));

FUNCTION


NAME

        _name_of_day - 

SYNTAX

string _name_of_day(int day)

DESCRIPTION

	Returns the name of the day. The following names are used:

		Larsday
		Q'sday
		Padsday
		Orsday
		Harday
		Leoday
		Matsday

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_name_of_day(TD->_weekday(TD->_time())));

FUNCTION


NAME

        _year - 

SYNTAX

mixed _year(int i, int flag, int give_str)

DESCRIPTION

	This function returns what year it is. Set flag to convert to 
	Nanny Time (tm). Set give_str to get the name of the year.

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_year(TD->_time(), 1, 0)); /* writes the year-number */
	write(TD->_year(TD->_time(), 1, 1)); /* writes the year-name */

FUNCTION


NAME

        _month - 

SYNTAX

mixed _month(int i, int flag, int give_str)

DESCRIPTION

	Returns the present month, beginning with month. 1 Set flag 
	to convert to Nanny Time (tm). Set give_str to get the name of 
	the month.

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_month(TD->_time(), 1, 0)); /* Gives a number */
	write(TD->_month(time(), 1, 1));      /* Gives a name   */

FUNCTION


NAME

        _mday - 

SYNTAX

int _mday(int i, int flag)

DESCRIPTION

	Returns the day of the present month, beginning with day 1. Set flag 
	to convert to Nanny Time (tm).

EXAMPLE

	Write the number of the day in the current Nanny-month:
	#define TD "/obj/util/timed"
	write(TD->_mday(TD->_time(), 1));

FUNCTION


NAME

        _weekday - 

SYNTAX

mixed _weekday(int i, int flag, int str)

DESCRIPTION

	Returns the present day of week, beginning with day 1. Set flag 
	to convert to Nanny Time (tm). Set give_str to get the name of 
	the month.

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_weekday(TD->_time(), 1, 0)); /* Gives a number */
	write(TD->_weekday(time(), 1, 1));      /* Gives a name   */

FUNCTION


NAME

        nanny_time2 - 

SYNTAX

int nanny_time2()

DESCRIPTION

	Prints some assorted time info.

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->nanny_time());
	/* prints:
	   Wed Oct  4 10:50:24 1995
	   Larsday The Month of Darkness 01  6:50:24 The Year of Light
	   31 years 0 month 0 day 6 hours 50 minutes 24 seconds.
	   Phase : Full moon
	*/

FUNCTION


NAME

        _ctime - 

SYNTAX

varargs mixed _ctime(int time, int flag, int give_array)

DESCRIPTION

        This lfun is similar to the efun ctime(). _ctime() converts an
	integer with NannyTime to a formatted string with the absolute
	NannyMUD date.

	Use the 'flag' to turn the argument into NannyTime before the
	conversion to string is done.
	
	Use the argument 'give_array' to skip the conversion to string
	altogether. Instead, an array with the parts will be returned:
	({ year, month, day, weekday, hour, minute, second }).

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_ctime(time(),1));
	/* prints something in this format:
		Q'sday The Month of Darkness 02  0:27:59 The Year of Light
	*/

FUNCTION


NAME

        _dtime - 

SYNTAX

varargs mixed string _dtime(int i, int give_array)

DESCRIPTION

	Converts an integer with NannyTime(tm) to a formatted string
	with relative time. If the 'give_array' argument is given, it
	returns an array with the parts: ({ years, months, days, hours,
	minutes, seconds }).

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_dtime(this_player()->query_age()));
	/* prints something in this format:
	   1 year 3 months 8 days 1 hour 26 minutes 43 seconds
	*/

FUNCTION


NAME

        _time_of_day - 

SYNTAX

mixed _time_of_day(int time, int flag, int give_str)

DESCRIPTION

	Converts an integer with NannyTime(tm) to a formatted string
	with the time of day. Set flag to convert time into NannyTime(tm).
	If give_str is 0, _time_of_day(...) returns an array ({hh, mm, ss}),
	else it returns a string: 8:50:16.

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_time_of_day(time(), 1, 1));
	/* prints something in this format:
	   8:50:16
	*/

FUNCTION


NAME

        _part_of_day - 

SYNTAX

mixed _part_of_day(int time, int flag, int give_str)

DESCRIPTION

	Converts an integer with NannyTime(tm) to a formatted string
	which tells if it is day or night or morning etc. Set flag to 
	convert time into NannyTime(tm).

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_part_of_day(time(), 1, 1));
	/* prints something in this format:
	   noon
	*/
	write(TD->_part_of_day(time(), 1, 0));
	/* prints something in this format:
	   5
	*/

FUNCTION


NAME

        dtime - 

SYNTAX

string dtime(int i)

DESCRIPTION

	Converts an integer with RLTime(tm) to a formatted string
	with relative time.

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->dtime(this_player()->query_age()));
	/* prints something in this format:
	   17 days 6 hours 46 minutes 53 seconds
	*/

FUNCTION


NAME

        _time - 

SYNTAX

int _time()

DESCRIPTION

	Returns the number of seconds since NannyMUD was first started.
	Very similar to the efun time().

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_time());
	/* prints something in this format:
	   172765898
	*/

FUNCTION


NAME

        nanny_time - 

SYNTAX

void nanny_time(int time, int flag)

DESCRIPTION

	Writes the time in a formatted way. Set flag if i is not in 
	NannyTime(tm) already.

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->nanny_time(time(), 1);
	/* prints something in this format:
	   31 years 0 months 4 days 5 hours 32 minutes 2 seconds.
	*/

FUNCTION


NAME

        _phase - 

SYNTAX

mixed _phase(int time, int flag, int give_str)

DESCRIPTION

	This function returns the moon-phase of Nanny's moon. time is 
	an int of the time when moon-phase is to be calculated. Set flag 
	if time is not in NannyTime(tm) already. If give_str is 1, _phase
	will return a string.

	MOONCYCLES

   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

   F 3 H 1 E 1 H 3 F  3  H  1  E  1  H  3  F  3  H  1  E  1  H  3  F  3  H  1

   0 1 2 3 4 5 6 7 0  1  2  3  4  5  6  7    

   F == Full, H == Half, E == Empty 1= 1 Quarter full, 3 = 3 Quarters full

	By define is : Day One is a Full moon night.

EXAMPLE

	#define TD "/obj/util/timed"
	write(TD->_phase(time(), 1, 1); 
		/* prints: Three quarters full moon, declining */
	write(TD->_phase(time(), 1, 0); /* prints: 1 */

FUNCTION


NAME

        query_season - 

SYNTAX

varargs string query_season(status autumn)

DESCRIPTION

        Returns the current season. If the autumn value is given, it
        will return "autumn" instead of "fall", if that is indeed the
        season.
	Winter consists of the months 12, 13, 1 and 2.
	Spring consists of the months 3, 4 and 5.
	Summer consists of the months 6, 7 and 8.
	Fall consists of the months 9, 10 and 11.

FUNCTION


NAME

        query_second - 

SYNTAX

int query_second()

DESCRIPTION

        Returns the seconds value of the minute of the hour of the day.

EXAMPLE

        If the time is 18:10:24, the result is 24.

FUNCTION


NAME

        query_minute - 

SYNTAX

int query_minute()

DESCRIPTION

        Returns the minute value of the hour of the day.

EXAMPLE

        If the time is 18:10:24, the result is 10.

FUNCTION


NAME

        query_hour - 

SYNTAX

int query_hour()

DESCRIPTION

        Returns the hour of the day.

EXAMPLE

        If the time is 18:10:24, the result is 18.

FUNCTION


NAME

        query_day_part - 

SYNTAX

varargs string query_day_part(status afternoon)

DESCRIPTION

        Returns the part of the day. If the afternoon flag is given,
        the "noon" part of the day will be replaced by "afternoon", if
        indeed it is that part of the day. This is useful in some
        instances of grammar.

FUNCTION


NAME

        query_weekday - 

SYNTAX

varargs mixed query_weekday(status name)

DESCRIPTION

        Returns the day of the week. If name is given, it will return
        the name in string format. Otherwise it will return the
        numerical day within the week.

FUNCTION


NAME

        query_month - 

SYNTAX

varargs mixed query_month(status name)

DESCRIPTION

        Returns the current month. If name is given, it will return
        the name in string format. Otherwise it will return the
        number of the month in the year.

FUNCTION


NAME

        query_year - 

SYNTAX

varargs mixed query_year(status name)

DESCRIPTION

        Returns the current year. If name is given, it will return
        the name in string format. Otherwise it will return the
        number of the year in the year cycle.

FUNCTION


NAME

        query_moon_phase - 

SYNTAX

varargs string query_moon_phase(int part_of_string)

DESCRIPTION

        Returns the phase of the moon in string format. If
        part_of_string is 1, it will return the first part of the string.
        If part_of_string is 2, it will return the second part. By
        default, it returns a single string that contains both.

NOTE

        In cases when the moon is neither waning nor waxing,
        query_moon_phase(1) returns "", which may result in an unwanted,
        extra space in a sentence. Write your descriptions carefully.

EXAMPLE

        query_moon_phase(1) returns "waning"

EXAMPLE

        query_moon_phase(2) returns "gibbous"

EXAMPLE

        query_moon_phase()  returns "waning gibbous"

FUNCTION


NAME

        query_daytime - 

SYNTAX

status query_daytime()

DESCRIPTION

        Returns true if it's not nighttime.

NOTE

        Daytime here is defined as when the sun is visible. Therefore,
        "evening" is still considered daytime.

FUNCTION


NAME

        query_night - 

SYNTAX

status query_night()

DESCRIPTION

        Returns true if it is nighttime.

FUNCTION


NAME

        query_moon_cycle - 

SYNTAX

int query_moon_cycle()

DESCRIPTION

        Returns a numerical value for the moon's position in the sky.
        A value of 0 to 8 means the moon is on this side of the globe.
        A value of 9 to 19 means the moon is on the OTHER side of the
        globe (and therefore ABSOLUTELY not visible).

        By definition, the moon cycles Nanny once every 18 hours, and
        starts to rise in the west on day zero.

SEE ALSO

        query_moon in daemon/timed

SEE ALSO

        query_moon_position in daemon/timed

FUNCTION


NAME

        query_moon - 

SYNTAX

status query_moon()

DESCRIPTION

        Returns true if the moon is visible in the sky. It checks to
        see if the moon is on this side of the globe and also checks
        to see that it is NOT a new moon. 

NOTE

        Does not account for cloud cover, which is handled by the
        "atmosphere" property.

        The moon IS visible in the daytime.

SEE ALSO

        query_moon_phase in daemon/timed

FUNCTION


NAME

        query_moon_position - 

SYNTAX

varargs string query_moon_position(int part_of_string)

DESCRIPTION

        If the moon is visible, this function returns its position
        in the sky. If part_of_string is 1, only the first part
        of its position will be given. If part_of_string is 2,
        only the second part will be given. By default, it returns
        the entire string.

EXAMPLE

        For a given position,
        query_moon_position(1) returns "low"
        query_moon_position(2) returns "western"
        query_moon_position()  returns "low in the western sky"

SEE ALSO

        query_moon_cycle in daemon/timed

FUNCTION


NAME

        query_sun_position - 

SYNTAX

varargs string query_sun_position(int part_of_string)

DESCRIPTION

        If it's daytime, this returns the sun's position in the sky.
        If part_of_string is 1, only the first part of its position will
        be given. If part_of_string is 2, only the second part will be
        given. By default, it returns the entire string.

EXAMPLE

        For a given time,
        query_sun_position(1) returns "low"
        query_sun_position(2) returns "western"
        query_sun_position()  returns "low in the western sky"

FUNCTION


NAME

        ctime_to_time - time-string to time-int conversion

SYNTAX

        int ctime_to_time(string ctime_str)

DESCRIPTION

        Given a string of the format returned by ctime(), compute the
	time 't' that time() returned for at time.

EXAMPLE

        ctime_to_time("Sat Aug 23 09:19:24 2003") --> 1061623164
        ctime(1061623164) --> "Sat Aug 23 09:19:24 2003"