PHP Classes

File: documentation/class.chronos.documentation

Recommend this page to a friend!
  Classes of stefan rusterholz   Chronos   documentation/class.chronos.documentation   Download  
File: documentation/class.chronos.documentation
Role: Documentation
Content type: text/plain
Description: Plaintext Documentation
Class: Chronos
Manipulate and format dates, times and intervals
Author: By
Last change: Moved to the correct directory
Made it accessible without login
Date: 17 years ago
Size: 57,660 bytes
 

Contents

Class file image Download
INDEXING Package: Chronos Author: Stefan Rusterholz Contact: stefan@brightlight.ch Version: 0.9.2 Date: 2005-02-23 [1109171542] Tabulator: 4 spaces THIS DOCUMENT This document is written in ISO-Latin-1 with Unix-Lineendings. Tabulator uses 4 spaces. I don't like it if code is cramed with comments. In my oppinion the code itself should be as readable as possible (no short variable names, no abbreviated function names). But of course that doesn't make documentation obsolete, that's why this document exists. DESCRIPTION The package chronos consists of the classes datetime, difference, timespan, location and chronos which are intended to let you easily deal with everything related to time & date. It allows you to deal with: -different languages (userinput & output) -different timezones (conversion & handling) -daylight saving times (handling) -different startdays for week -comparison of dates/times/datetimes/differences -addition of dates with differences or differences -subtraction of dates with differences or differences -some special "goto" methods (to quickly get n. week of the year or month, the n. day of the year, week or month, ...) -output dates/times/datetimes/differences in many useful ways (e.g. humand readably, unixtime, mysql-formatted, ...) -deal with some special interests (pull out zodiac, age etc. from dates immediatly) -Since it only rarely uses the unix libraries it is not restricted to it's limits (eg. only from 1970-2038) -Retrieving fractions of dates/times/datetimes/differences (e.g. how many months are in that difference, the howmaniest day of the year is it, ...) What this library does not do for you: -it is not (yet) aware of leapseconds -it assumes all dates are gregorian, it doesn't deal in a special way with dates before introduction of the gregorian calendar* -it is not aware of all daylight saving time exceptions around the world and time *See NOTES, different behaviour is difficult IMMINENT CHANGES Be aware that this class is a pre 1.0 release and I probably will change some of the interfaces and functions What I'm still unhappy with is: -creation of difference (I want to drop the $from and automatically detect how to create it) -creation of chronos (is timezone really more important then language?) -handling of locations (for local usage we don't need to carry the whole file around and read it every time, that's waste of resources) -format of strings-files -implementation of DST could change some behaviours (think about adding 1 month to a datetime which then shifts from non-DST to DST and vice-versa - what happens to the time?) -implementation of leapseconds, which could change some behaviours of adding-/subtracting-methods -reorganizing code in a way that advanced functions like sun-calculations are only loaded if needed (the class is 90K at the moment and I think most users will only use functions that would need 30K, so 60K that we could load optionally) -implementation of non-ISO-8601 for week of year (the ISO way to do it can be very unhandy since it is sometimes ambivalent) NORMS & LINKS Dates: -ISO 8601 weeknumber Times: -DIN 5034 sunrise/sunset algorithm Locations: -ISO 6709 sign-degrees-minutes-seconds format (longitude/latitude) -ISO 3166 two-letter country codes http://de.wikipedia.org/wiki/ISO_3166_Kodierliste http://de.wikipedia.org/wiki/ISO_3166 http://www.iso.org/iso/en/prods-services/iso3166ma/02iso-3166-code-lists/index.html Timezones: http://www.timezoneconverter.com/cgi-bin/tzref.tzc http://www.timeanddate.com/worldclock/converter.html NOTES -year can range from 1 to 9999 -month can range from 1 to 12, where 1 is normally January -week can range from 1 to 53 -weekday can range from 1 to 7, where 1 is normally starting day of week (per default 'Monday'). -day can range from 1 to 31 You can change that by changing the $starts-property in Chronos For language files, 1 always refers to Monday, 2 to Tuesday and so on -per default a year starts with 1.1. -datetimes are not consistent in addition/subtraction Example: 31.3. +1month = ? My Solution: 31.3. +1month = 31.4.(overflow) => 1.5. Now, whats 1.5. -1month? My Solution: 1.5. -1month = 1.4. Problem: 31.3. +1month-1month != 31.3. If you have a *usable* solution to this problem, let me know -If you use those classes, please notify me. -If you make changes you're not only asked but even forced by the license -Please help me to improve this class. If you see an error in the docs (I'm not a native english-speaker), let me know. -I'm very interested in other language files. -I'm too interested in information how to correctly include handling of DST all over the world. -I'm slightly interested in a way to integrate older non-gregorian calendars. Be aware that for the latter you have to regard the different dates of introduction (russia, europa and some europian countries differ in the date of adoption) BUGS -all dates treated as gregorian even before 15. october 1582 (and the leap from 4. oct 1582 to 15. is not implemented) -leapseconds are ignored -DST implementation incomplete -not yet safe to change start-property TODO -difference::create_fromString() -location::get_timezoneName($format=false) -location::get_offset() -location::get_isDST() [will probably be moved to chronos anyway] -timespan::count_weeks() -chronos::convert_toDatetime() -integrate error handling (especially for creation of datetimes from strings) -integrate DST -make it more consistent -improve subtractDatetime in a way that if possible the difference is positive or negative numbers only -enable procedural usage of methods where it makes sense -today_moon_phase(string $date) -find other algorithms for sunrise/sunset/twilight (DIN 5034 e.g., at the moment it seems we use NREL SOLPOS) -check timezones -convert var $lookups into a chronos::lookup() method which can be used procedurally (allows some other functions to be used procedurally too) -datetime::create_fromString() -chronos::include_exists() CLASSES & METHODS class datetime method datetime($datetime, $timezoneID, $language) Synopsis: // timezone will be local timezone, language is 'en' $now = new datetime("current"); // another variant of the sample above $now = new datetime(time()); // language will be 'de' (default for Europe/Zurich) $date = new datetime("2005-12-31", "Europe/Zurich"); // you can create time-only objects as well $time = new datetime("13:45:21", "Europe/Zurich"); // this pattern will be recognized because german-strings are loaded $datetime = new datetime("31.12.2005 13:45", , "Europe/Zurich", "de"); // you can create from an array $datetime = new datetime(array('day' => 31, 'month' => 12, 'year' => 2005, 'hour' => 13, 'minute' => 45), "Europe/Zurich"); Return: VOID Creates a new Object Arguments: MIXED $datetime: the datetime to create the new object from. Can be either an array with the keys ('day', 'month', 'year') or ('week','dayofweek','year') for date and/or ('hour','minute','second') for time. For missing date-parts the default value is current-date (e.g. if you ommit year the current year will be taken). For missing time-parts the default value is 0 (e.g. if you ommit the seconds it will be set to 0). STRING $timezoneID: Either one of the timezone-id's like America/Los_Angeles (see data.locations.tab) or use a utc-name 'UTC±difference' like 'UTC', 'UTC+1' or 'UTC-4'. Timezone-IDs are prefered since they can determine the whished language, DST-behaviour and geographic position as well. STRING $language: An ISO 3166 two-letter-countrycode (like 'en', 'de' or 'fr'). The language parameter will override the setting retrieved from a timezone-ID. This can be useful if you want to print a date from another country but in your language. Description: Creates a new date/time object from $datetime using create_fromString (if $datetime is a string), create_fromUnixtime (if $datetime is an integer) or create_fromArray (if $datetime is an array). method create_fromString($string, $croak) Synopsis: $result = $datetime->create_fromString('1/1/2005 13.45', false); Return: BOOL Success Arguments: STRING $string: A string containing a date and/or time in any format known in the loaded language files BOOL $croak: If $croak is true the function will trigger an error if it can not match the string or if the recognized date is corrupt. Set this to false if you want to parse e.g. formular input where it is not sure that a date/time can be matched. Description: Sets the date/time from a human- or machine-readable string. Useful for date/time fields in forms. method create_fromUnixtime($unixtime) Synopsis: $result = $datetime->create_fromUnixtime(1108500000); Return: BOOL Success Arguments: INT $unixtime: The unixtimestamp from which you want to create a datetime-object. Description: Set the date/time from a unixtimestamp. method create_fromMySQL($integer) Synopsis: $result = $datetime->create_fromMySQL('2005-01-20 12:00:00'); $result = $datetime->create_fromMySQL('20050120120000'); // the same as above Return: BOOL Success Arguments: STRING $integer: A MySQL datetime stamp in either the integer-format (yyyymmddHHMMSS) or string-format ('yyyy-mm-dd HH:MM:SS'). Description: Set the date/time from a MYSQL-datetime or -timestamp field. method create_fromCurrent() Synopsis: $result = $datetime->create_fromCurrent(); Return: BOOL Success Description: Sets date and time to current date and time. method create_fromArray($array) Synopsis: // sets datetime to '2005-01-20 12:59:02' $result = create_fromArray(array('year' => 2005, 'month' => 1, 'day' => 20, 'hour' => 12, 'minute' => 59, 'second' => 2); // sets datetime to 'current year-01-20 12:00:00' $result = create_fromArray(array('month' => 1, 'day' => 20, 'hour' => 12); Return: BOOL Success Arguments: ARRAY $array: The components of date/time, can use the keys: year, month, day, hour, minute, second, timezone If no date-part is supplied a time-object is created. If no time-part is supplied a date-object is created. If at least one date-part is supplied, the default for omitted date-parts is the current date (e.g. you ommit the year, then the current year will be taken) If at least one time-part is supplied, the default for omitted time-parts is 0. Description: Set time/date from an array containing the parts. We make an educated guess what defaults to take. Idea is following: -if a datepart is supplied we fill in gaps with current date (e.g. month and day are supplied we complement year with current year) -if a timepart is supplied we fill in gaps with 0 -timezone: argument > creation-supplied > default (means: if given in the array, that value will be taken, else it falls back to the timezone given at creation or in worst case uses default) method set_micro($micro) Synopsis: $result = $datetime->set_micro(456); Return: BOOL Success Arguments: INT $micro: Set the microseconds-part of a datetime-object to $micro Description: Set the microseconds-part of the time Date-Objects will automatically become datetime-object if this method is used. method set_milli($milli) Synopsis: $result = $datetime->set_milli(123); Return: BOOL Success Arguments: INT $milli: Set the milliseconds-part of a datetime-object to $milli Description: Set the milliseconds-part of the time Date-Objects will automatically become datetime-object if this method is used. method set_second($second) Synopsis: $result = $datetime->set_second(52); Return: BOOL Success Arguments: INT $second: Set the seconds-part of a datetime-object to $second Description: Set the seconds-part of the time Date-Objects will automatically become datetime-object if this method is used. method set_minute($minute) Synopsis: $result = $datetime->set_minute(45); Return: BOOL Success Arguments: INT $minute: Set the minutes-part of a datetime-object to $minute Description: Set the minutes-part of the time Date-Objects will automatically become datetime-object if this method is used. method set_hour($hour) Synopsis: $result = $datetime->set_hour(13); Return: BOOL Success Arguments: INT $hour: Set the hours-part of a datetime-object to $hour Description: Set the hours-part of the time Date-Objects will automatically become datetime-object if this method is used. method set_day($day, $month, $year) Synopsis: $result = $datetime->set_day(21); Return: BOOL Success Arguments: INT $day: The day of the year to which the date should be set. It will become converted to the according month and day of month. INT $month: The month of which the day is set. If set to false, get_month() is used. You should NOT use this argument, it is only for internal purposes. INT $year: The year of which the day is set. If set to false, get_year() is used. You should NOT use this argument, it is only for internal purposes. Description: Set the day of the month to $day. method set_dayOfYear($dayOfYear, $year) Synopsis: $result = $datetime->set_dayOfYear(121); Return: BOOL Success Arguments: INT $dayOfYear: The day of the year to which the date should be set. It will become converted to the according month and day of month. INT $year: The year of which the day-of-year is set. If set to false, get_year() is used. You should NOT use this argument, it is only for internal purposes. Description: Set the date (day-of-month and month) to a specific day of the year. method set_month($month) Synopsis: $result = $datetime->set_month(1); Return: BOOL Success Arguments: INT $month: The month to which the date should be set. Description: Set the month to $month. method set_year($year) Synopsis: $result = $datetime->set_year($year); Return: BOOL Success Arguments: INT $year: The year to which the date should be set. Description: Set the year to $year. method setTo_nthDayOfWeek($n) Synopsis: // set date to monday $result = $datetime->setTo_nthDayOfWeek(0); Return: BOOL Success Arguments: INT $n: Date set to {$n}th day of week, time is preserved If $n is negative date is set to the {$n}th-last day of week Description: Set the date to a specific weekday of the current week. method setTo_nthDayOfMonth($n) Synopsis: // set date to last day of the month $result = $datetime->setTo_nthDayOfMonth(-1); Return: BOOL Success Arguments: INT $n: Date set to {$n}th day of month, time is preserved If $n is negative date is set to the {$n}th-last day of month Description: Set the date to a specific day of month. method setTo_nthDayOfYear($n) Synopsis: // set date to last day of the year $result = $datetime->setTo_nthDayOfYear(-1); Return: BOOL Success Arguments: INT $n: Date set to {$n}th day of year, time is preserved If $n is negative date is set to the {$n}th-last day of year Description: Set the date to a specific day of the year. method setTo_nthWeekOfYear($n, $weekday) Synopsis: // set the date to the same weekday as it is at the moment but in the first week of the year $result = $datetime->setTo_nthWeekOfYear(1, false); // set the date to monday of the first week of the year $result = $datetime->setTo_nthWeekOfYear(1, 0); Return: BOOL Success Arguments: INT $n: Date set to {$n}th week of year, time is preserved INT $weekday: Date set to weekday $weekday (false for preserving current weekday) Description: Set the date to a specific weekday of a specific week of the year. method setTo_sunrise($location) Synopsis: // Set the time to the time of the sunrise $result = $datetime->setTo_sunrise(); Return: BOOL Success Arguments: MIXED $location: False (default) for using current timezone-ID's coordinates A location object A coordinates-array in form: array([FLOAT]latitude, [FLOAT]longitude) A string containing a valid timezoneID Description: Changes time of datetime object to the time of sunrise in location $location method setTo_sunset($location) Synopsis: $result = $datetime->setTo_sunset($location); Return: BOOL Success Arguments: MIXED $location: False (default) for using current timezone-ID's coordinates A location object A coordinates-array in form: array([FLOAT]latitude, [FLOAT]longitude) A string containing a valid timezoneID Description: Changes time of datetime object to the time of sunset in location $location method setTo_morningTwilight($location) Synopsis: $result = $datetime->setTo_morningTwilight($location); Return: BOOL Success Arguments: MIXED $location: False (default) for using current timezone-ID's coordinates A location object A coordinates-array in form: array([FLOAT]latitude, [FLOAT]longitude) A string containing a valid timezoneID Description: Changes time of datetime object to the time of morning-twilight in location $location method setTo_eveningTwilight($location) Synopsis: $result = $datetime->setTo_eveningTwilight($location); Return: BOOL Success Arguments: MIXED $location: False (default) for using current timezone-ID's coordinates A location object A coordinates-array in form: array([FLOAT]latitude, [FLOAT]longitude) A string containing a valid timezoneID Description: Changes time of datetime object to the time of evening-twilight in location $location method do_add($differenceOrArray) Synopsis: $result = $datetime->do_add($differenceOrArray); Return: BOOL Success Arguments: MIXED $differenceOrArray: Difference-Object or array with one or more of the keys 'seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years' Description: Adds a datetime-difference (any combination of seconds, minutes, hours, days, weeks, months and years) to the datetime. method do_addSeconds($seconds) Synopsis: $result = $datetime->do_addSeconds($seconds); Return: BOOL Success Arguments: INT $seconds: Amount of seconds to add Description: Adds $seconds seconds to the datetime. method do_addMinutes($minutes) Synopsis: $result = $datetime->do_addMinutes($minutes); Return: BOOL Success Arguments: INT $minutes: Amount of minutes to add Description: Adds $seconds seconds to the datetime. method do_addHours($hours) Synopsis: $result = $datetime->do_addHours($hours); Return: BOOL Success Arguments: INT $hours: Amount of seconds to add Description: Adds $hours hours to the datetime. method do_addDays($days) Synopsis: $result = $datetime->do_addDays($days); Return: BOOL Success Arguments: INT $days: Amount of days to add Description: Adds $days days to the datetime. method do_addMonths($months, $cutOverflow) Synopsis: $result = $datetime->do_addMonths($months, $cutOverflow); Return: BOOL Success Arguments: INT $months: Amount of months to add BOOL $cutOverflow: If overflow days should be added or just cut Description: Adds $monts monts to the datetime. If cutOverflow is false, then 31.3. +1month is eqal 1.5. Else it is equal 30.4. (since there is no 31.4.). method do_addYears($years) Synopsis: $result = $datetime->do_addYears($years); Return: BOOL Success Arguments: INT $years: Amount of years to add Description: Adds $years years to the datetime. method do_subtractDatetime($subtrahend) Synopsis: $result = $datetime->do_subtractDatetime($subtrahend); Return: BOOL Success Arguments: OBJECT $subtrahend: Datetime-Object to subtract from $this Description: Subtracts a datetime from the datetime. This operation changes the object-type to a difference-object. You can use datetime->do_subtract() instead. method do_subtract($differenceDatetimeOrArray) Synopsis: $result = $datetime->do_subtract($differenceDatetimeOrArray); Return: BOOL Success Arguments: MIXED $differenceDatetimeOrArray: Difference-, Datetime-Object or array with one or more of the keys 'seconds', 'minutes', 'hours', 'days', 'weeks', 'months', 'years' Description: Subtracts a datetime or a datetime-difference (any combination of seconds, minutes, hours, days, weeks, months and years) from the datetime. If you subtract a datetime the object-type will be changed to a difference-object. method do_subtractSeconds($seconds) Synopsis: $result = $datetime->do_subtractSeconds($seconds); Return: BOOL Success Arguments: INT $seconds: Amount of seconds to subtract Description: Subtracts $seconds seconds from the datetime. method do_subtractMinutes($minutes) Synopsis: $result = $datetime->do_subtractMinutes($minutes); Return: BOOL Success Arguments: INT $minutes: Amount of minutes to subtract Description: Subtracts $minutes minutes from the datetime. method do_subtractHours($hours) Synopsis: $result = $datetime->do_subtractHours($hours); Return: BOOL Success Arguments: INT $hours: Amount of hours to subtract Description: Subtracts $hours hours from the datetime. method do_subtractDays($days) Synopsis: $result = $datetime->do_subtractDays($days); Return: BOOL Success Arguments: INT $days: Amount of days to subtract Description: Subtracts $days days from the datetime. method do_subtractMonths($months, $cutOverflow) Synopsis: $result = $datetime->do_subtractMonths($months, $cutOverflow); Return: BOOL Success Arguments: INT $years: Amount of years to subtract BOOL $cutOverflow: If overflow days should be added or just cut Description: Subtracts $years years from the datetime. If cutOverflow is false, then 31.3. +1month is eqal 1.5. Else it is equal 30.4. (since there is no 31.4.). method do_subtractYears($years) Synopsis: $result = $datetime->do_subtractYears($years); Return: BOOL Success Arguments: INT $years: Amount of years to subtract Description: Subtracts $years years from the datetime. method get_nthDayOfWeek($n) Synopsis: $result = $datetime->get_nthDayOfWeek($n); Return: OBJECT The datetime-object set to the n. day of the week Arguments: INT $n: Date set to {$n}th day of week, time is preserved If $n is negative date is set to the {$n}th-last day of week Description: Return a new datetime object with the date set to a specific weekday of the current week. method get_nthDayOfMonth($n) Synopsis: $result = $datetime->get_nthDayOfMonth($n); Return: OBJECT The datetime-object set to the n. day of the month Arguments: INT $n: Date set to {$n}th day of month, time is preserved If $n is negative date is set to the {$n}th-last day of month Description: Return a new datetime object with the date set to a specific day of month. method get_nthDayOfYear($n) Synopsis: $result = $datetime->get_nthDayOfYear($n); Return: OBJECT The datetime-object set to the n. day of the year Arguments: INT $n: Date set to {$n}th day of year, time is preserved If $n is negative date is set to the {$n}th-last day of year Description: Return a new datetime object with the date set to a specific day of the year. method get_nthWeekOfYear($n, $weekday) Synopsis: $result = $datetime->get_nthWeekOfYear($n, $weekday); Return: OBJECT The datetime-object set to a specific weekday of the n. week of the year Arguments: INT $n: Date set to {$n}th week of year, time is preserved INT $weekday: Date set to weekday $weekday (false for preserving current weekday) Description: Return a new datetime object with the date set to a specific weekday of a specific week of the year. method get_dayOfWeek($format) Synopsis: $result = $datetime->get_dayOfWeek($format); Return: MIXED Returns the day of week in a form depending on $format. Numeric values range from 0-6, where 0 represents the start of the week (monday). Arguments: STRING $format: Specifies in what format the day-of-week is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the day of the week -'integer': will return the day of the week as integer -'string': will look up the weekdays name in the active language file Description: Return the weekday either as integer, padded-integer or localized string. method get_dayOfMonth($format) Synopsis: $result = $datetime->get_dayOfMonth($format); Return: MIXED Returns the day of month in a form depending on $format. Numeric values range from 1-31. Arguments: STRING $format: Specifies in what format the day-of-month is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the day of the month -'integer': will return the day of the month as integer Description: Return the day of month either as integer or as padded-integer. method get_dayOfYear($format) Synopsis: $result = $datetime->get_dayOfYear($format); Return: MIXED Returns the day of year in a form depending on $format. Numeric values range from 1-366. Arguments: STRING $format: Specifies in what format the day-of-year is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the day of the year -'integer': will return the day of the year as integer Description: Return the day of month either as integer or as padded-integer. method get_daysOfMonth($month, $year) Synopsis: $result = $datetime->get_daysOfMonth($month, $year); Return: INT Amount of days of month $month of year $year. Arguments: INT $month: Month of which you want to know the amount of days. Uses $this->get_month() if set to false. INT $year: Year in which the month is (only important for february). Uses $this->get_year() if set to false. Description: Returns the amount of days of month $month of year $year. method get_weeksOfYear($year) Synopsis: $result = $datetime->get_weeksOfYear($year); Return: INT Amount of weeks (52-53) year $year has. Arguments: INT $year: Year of which to return amount of weeks. Uses $this->get_year() if set to false. Description: Returns the amount of weeks year $year has. method get_monthFromYearday($day, $year) Synopsis: $result = $datetime->get_monthFromYearday($day, $year); Return: INT The month (1-12) in which the day-of-year $day is. Arguments: INT $day: Day of year from which you want to know in which month it is. INT $year: Year in which the month is. Uses $this->get_year() if set to false. Description: Returns the month (1-12) in which the day-of-year $day is. method get_monthDayFromYearday($day, $year) Synopsis: $result = $datetime->get_monthDayFromYearday($day, $year); Return: INT Day of month (1-31) which the day of year corresponds to. Arguments: INT $day: Day of year (1-365, 366 in leapyears). INT $year: Year in which the month is (only important for february). Uses $this->get_year() if set to false. Description: Returns the day of month (1-31) which the day of year corresponds to. method get_date() Synopsis: $result = $datetime->get_date(); Return: ARRAY Dump of the date-part of the object Description: Returns a dump of the date-part of the object. method get_time() Synopsis: $result = $datetime->get_time(); Return: ARRAY Dump of the time-part of the object Description: Returns a dump of the date-part of the object method get_datetime() Synopsis: $result = $datetime->get_datetime(); Return: ARRAY Dump of the date & time-part of the object Description: Returns a dump of the date & time-part of the object method get_year($digits, $asInt) Synopsis: $result = $datetime->get_year($digits, $asInt); Return: STRING Year of datetime Arguments: INT $digits: How many digits of the year to return (2 and 4 are common) BOOL $asInt: Return the year as integer rather then as string Description: Returns the year of datetime. method get_month($format) Synopsis: $result = $datetime->get_month($format); Return: MIXED The month in a form depending on $format. Numeric values range from 1-12. Arguments: STRING $format: Specifies in what format the month is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the month -'integer': will return the month as integer -'string': will look up the months name in the active language file Description: Return the month either as integer, padded-integer or localized string. Numeric values range from 1-12. method get_day($format) Synopsis: $result = $datetime->get_day($format); Return: MIXED Returns the day of month in a form depending on $format. Numeric values range from 1-31. Arguments: STRING $format: Specifies in what format the day-of-month is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the day of the month -'integer': will return the day of the month as integer Description: Return the day of month either as integer or as padded-integer. method get_hour($format, $mode) Synopsis: $result = $datetime->get_hour($format, $mode); Return: MIXED Hour either as integer or padded-integer. Numeric values range from 1-12 or 1-24 (see $mode). Arguments: STRING $format: Specifies in what format the hour is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the hour -'integer': will return the hour as integer INT $mode: Valid values are 12 and 24. Defines if the hour is returned as value 1-12 or as value 1-24. Description: Returns the hour either as integer or padded-integer. Numeric values range from 1-12 or 1-24 (see $mode). method get_minute($format) Synopsis: $result = $datetime->get_minute($format); Return: MIXED Returns the minute in a form depending on $format. Numeric values range from 0-59. Arguments: STRING $format: Specifies in what format the minute is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the minute -'integer': will return the minute as integer Description: Return the minute either as integer or as padded-integer. method get_second($format) Synopsis: $result = $datetime->get_second($format); Return: MIXED Returns the second in a form depending on $format. Numeric values range from 0-59. Arguments: STRING $format: Specifies in what format the second is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the second -'integer': will return the second as integer Description: Return the second either as integer or as padded-integer. method get_milli($format) Synopsis: $result = $datetime->get_milli($format); Return: MIXED Returns the millisecond in a form depending on $format. Numeric values range from 0-999. Arguments: STRING $format: Specifies in what format the millisecond is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the millisecond -'integer': will return the millisecond as integer Description: Return the millisecond either as integer or as padded-integer. method get_micro($format) Synopsis: $result = $datetime->get_micro($format); Return: MIXED Returns the microsecond in a form depending on $format. Numeric values range from 0-999. Arguments: STRING $format: Specifies in what format the microsecond is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the microsecond -'integer': will return the microsecond as integer Description: Return the microsecond either as integer or as padded-integer. method get_week($format) Synopsis: $result = $datetime->get_week($format); Return: MIXED The week in a form depending on $format. Numeric values range from 1-53. Arguments: STRING $format: Specifies in what format the week is returned. Valid are following values: -'alldigits': will return a padded number corresponding to the week -'integer': will return the week as integer Description: Return the week either as integer or as padded-integer. method get_zodiac() Synopsis: $result = $datetime->get_zodiac(); Return: STRING localized name of the zodiac Description: Returns the localized name of the zodiac for the datetime. method get_age() Synopsis: $result = $datetime->get_age(); Return: INT The difference of total years between datetime and today. Description: Returns the difference of total years between datetime and today. Useful for usermanagements where you want to extract the age of somebody e.g. method as_array() Synopsis: $result = $datetime->as_array(); Return: ARRAY An array containing all relevant values of datetime. Description: Returns an array containing all relevant values of datetime. method as_unixtime() Synopsis: $result = $datetime->as_unixtime(); Return: INT A unixtimestamp representation of datetime Description: Returns a unixtimestamp representation of datetime method as_mysqlDate($asInteger) Synopsis: $result = $datetime->as_mysqlDate(); Return: STRING A string-representation of date-part of datetime ready for mysql-queries Arguments: BOOL $asInteger: Return the value in the mysql-integer format for dates (yyyymmdd). Description: Returns a string-representation of date-part of datetime ready for mysql-queries method as_mysqlTime() Synopsis: $result = $datetime->as_mysqlTime($asInteger); Return: STRING A string-representation of date-part of datetime ready for mysql-queries Arguments: BOOL $asInteger: Return the value in the mysql-integer format for dates (HHMMSS). Description: Returns a string-representation of date-part of datetime ready for mysql-queries method as_mysqlDatetime($asInteger) Synopsis: $result = $datetime->as_mysqlDatetime($asInteger); Return: STRING A string-representation of datetime ready for mysql-queries Arguments: BOOL $asInteger: Return the value in the mysql-integer format for dates (yyyymmddHHMMSS). Description: Returns a string-representation of datetime ready for mysql-queries method as_string($pattern) Synopsis: $datetime = new datetime(); echo $datetime->as_string("%m/%d/%Y %H.%M"); --> 11/21/2005 13.45 echo $datetime->as_string("%B %{B|lc} %{monthname|uc|3}"); --> November november NOV Return: STRING The string containing the values as given in $pattern Arguments: STRING $pattern: How the string should be formatted, allowed are the two formats %<char>, %{string|modifier|...}. See @chronos::get_stringPart() and @chronos::get_appliedModificators() for more informations about the formatting. Description: Returns a formatted string of the datetime, comparable to strftime for unix-timestamps. Be aware that the advanced syntax (%{part|modifier|...}) is quite powerful. class difference method difference($from, $difference, $timezone, $language) Synopsis: $result = $difference->difference($from, $difference, $timezone, $language); Return: VOID Creates a new Object Arguments: STRING $from: One of the following values: 'string', 'array', 'exact' or 'nothing' MIXED $difference: the difference to create the new object from, the format depends on $from. STRING $timezone: Either one of the timezone-id's like America/Los_Angeles (see data.locations.tab) or use a utc-name 'UTC±difference' like 'UTC', 'UTC+1' or 'UTC-4'. Timezone-IDs are prefered since they can determine the whished language, DST-behaviour and geographic position as well. STRING $language: An ISO 3166 two-letter-countrycode (like 'en', 'de' or 'fr'). The language parameter will override the setting retrieved from a timezone-ID. This can be useful if you want to print a date from another country but in your language. Description: WARNING - This method is likely to change! Creates a new difference object from $difference using create_fromString, create_fromArray or create_fromExact. $timezone and $language are only needed if the object could become converted to a datetime (e.g. via addition of a datetime etc.). But you can set that after it become casted too if you want. $difference should be an array of form array(seconds, months) if you set $from to 'exact'. method create_fromString($string) Synopsis: // this method is currently non-functional Return: BOOL Success Arguments: TYPE $string: description Description: Creates method create_fromPart($amount, $part) Synopsis: $result = $difference->create_fromPart($amount, $part); Return: BOOL Success Arguments: TYPE $amount: description TYPE $part: description Description: description method create_fromDatetimes($datetime1, $datetime2) Synopsis: $result = $difference->create_fromDatetimes($datetime1, $datetime2); Return: BOOL Success Arguments: OBJECT $datetime1: Earlier datetime of the timespan from which you want to create the difference OBJECT $datetime2: Later datetime of the timespan from which you want to create the difference Description: Creates a difference by subtracting $datetime1 from $datetime2. method create_fromArray($array) Synopsis: $result = $difference->create_fromArray($array); Return: BOOL Success Arguments: TYPE $array: description Description: description method create_fromExact($seconds, $months) Synopsis: $result = $difference->create_fromExact($seconds, $months); Return: BOOL Success Arguments: TYPE $seconds: description TYPE $months: description Description: description method do_add($differenceDatetimeOrArray) Synopsis: $result = $difference->do_add($differenceDatetimeOrArray); Return: BOOL Success Arguments: TYPE $differenceDatetimeOrArray: description Description: description method do_subtract($differenceOrArray) Synopsis: $result = $difference->do_subtract($differenceOrArray); Return: BOOL Success Arguments: TYPE $differenceOrArray: description Description: description method get_seconds($part) Synopsis: $result = $difference->get_seconds($part); Return: TYPE description Arguments: TYPE $part: description Description: description method get_minutes($part) Synopsis: $result = $difference->get_minutes($part); Return: TYPE description Arguments: TYPE $part: description Description: description method get_hours($part) Synopsis: $result = $difference->get_hours($part); Return: TYPE description Arguments: TYPE $part: description Description: description method get_days($part) Synopsis: $result = $difference->get_days($part); Return: TYPE description Arguments: TYPE $part: description Description: description method get_weeks($part) Synopsis: $result = $difference->get_weeks($part); Return: TYPE description Arguments: TYPE $part: description Description: description method get_months($part) Synopsis: $result = $difference->get_months($part); Return: TYPE description Arguments: TYPE $part: description Description: description method get_years($part) Synopsis: $result = $difference->get_years($part); Return: TYPE description Arguments: TYPE $part: description Description: description method as_array($part) Synopsis: $result = $difference->as_array($part); Return: TYPE description Arguments: TYPE $part: description Description: description method as_string($pattern) Synopsis: $result = $difference->as_string($pattern); Return: TYPE description Arguments: TYPE $pattern: description Description: description class timespan method timespan($start, $end, $language, $timezone) Synopsis: $result = $timespan->timespan($start, $end, $language, $timezone); Return: VOID Creates a new Object Arguments: TYPE $start: description TYPE $end: description TYPE $language: description TYPE $timezone: description Description: description method count_weekdayOccurrences($day) Synopsis: $result = $timespan->count_weekdayOccurrences($day); Return: TYPE description Arguments: TYPE $day: description Description: description method count_monthOccurrences($month) Synopsis: $result = $timespan->count_monthOccurrences($month); Return: TYPE description Arguments: TYPE $month: description Description: description method count_weeks($mode) Synopsis: $result = $timespan->count_weeks($mode); Return: TYPE description Arguments: TYPE $mode: description Description: description class location method location($location) Synopsis: $result = $location->location($location); Return: VOID Creates a new Object Arguments: TYPE $location: description Description: description method set_location($location) Synopsis: $result = $location->set_location($location); Return: TYPE description Arguments: TYPE $location: description Description: description method set_pseudoLocation($data) Synopsis: $result = $location->set_pseudoLocation($data); Return: TYPE description Arguments: TYPE $data: description Description: description method set_language($lang) Synopsis: $result = $location->set_language($lang); Return: TYPE description Arguments: TYPE $lang: description Description: description method do_readData($file) Synopsis: $result = $location->do_readData($file); Return: TYPE description Arguments: TYPE $file: description Description: description method is_validID($timezoneID) Synopsis: $result = $location->is_validID($timezoneID); Return: TYPE description Arguments: TYPE $timezoneID: description Description: description method get_language() Synopsis: $result = $location->get_language(); Return: TYPE description Description: description method get_utc() Synopsis: $result = $location->get_utc(); Return: TYPE description Description: description method get_timezoneName($format) Synopsis: $result = $location->get_timezoneName($format); Return: TYPE description Arguments: TYPE $format: description Description: description method get_countryAlpha2() Synopsis: $result = $location->get_countryAlpha2(); Return: TYPE description Description: description method get_countryAlpha3() Synopsis: $result = $location->get_countryAlpha3(); Return: TYPE description Description: description method get_numeric() Synopsis: $result = $location->get_numeric(); Return: TYPE description Description: description method get_timezoneID() Synopsis: $result = $location->get_timezoneID(); Return: TYPE description Description: description method get_rawOffset() Synopsis: $result = $location->get_rawOffset(); Return: TYPE description Description: description method get_offset($atDatetime) Synopsis: $result = $location->get_offset($atDatetime); Return: TYPE description Arguments: TYPE $atDatetime: description Description: description method get_latitude($format) Synopsis: $result = $location->get_latitude($format); Return: TYPE description Arguments: TYPE $format: description Description: description method get_longitude($format) Synopsis: $result = $location->get_longitude($format); Return: TYPE description Arguments: TYPE $format: description Description: description method get_isDST($atDatetime) Synopsis: $result = $location->get_isDST($atDatetime); Return: TYPE description Arguments: TYPE $atDatetime: description Description: description method get_DSTrule() Synopsis: $result = $location->get_DSTrule(); Return: TYPE description Description: description class chronos method chronos($timezoneID, $language) Synopsis: $result = $chronos->chronos($timezoneID, $language); Return: VOID Creates a new Object Arguments: TYPE $timezoneID: description TYPE $language: description Description: description method load_stringsFile($lang) Synopsis: $result = $chronos->load_stringsFile($lang); Return: TYPE description Arguments: TYPE $lang: description Description: description method unset_dateTimeAndDifference() Synopsis: $result = $chronos->unset_dateTimeAndDifference(); Return: TYPE description Description: description method unset_time() Synopsis: $result = $chronos->unset_time(); Return: TYPE description Description: description method unset_date() Synopsis: $result = $chronos->unset_date(); Return: TYPE description Description: description method unset_difference() Synopsis: $result = $chronos->unset_difference(); Return: TYPE description Description: description method unset_differenceDate() Synopsis: $result = $chronos->unset_differenceDate(); Return: TYPE description Description: description method set_defaults($timezone) Synopsis: $result = $chronos->set_defaults($timezone); Return: TYPE description Arguments: TYPE $timezone: description Description: description method set_is($date, $time, $difference) Synopsis: $result = $chronos->set_is($date, $time, $difference); Return: TYPE description Arguments: TYPE $date: description TYPE $time: description TYPE $difference: description Description: description method set_timezone($timezoneID) Synopsis: $result = $chronos->set_timezone($timezoneID); Return: TYPE description Arguments: TYPE $timezoneID: description Description: description method set_language($language) Synopsis: $result = $chronos->set_language($language); Return: TYPE description Arguments: TYPE $language: description Description: description method do_convertTimezone($newTimezoneID) Synopsis: $result = $chronos->do_convertTimezone($newTimezoneID); Return: TYPE description Arguments: TYPE $newTimezoneID: description Description: description method is_chronos($object, $class) Synopsis: $result = $chronos->is_chronos($object, $class); Return: TYPE description Arguments: TYPE $object: description TYPE $class: description Description: description method is_time($exclusive, $object) Synopsis: $result = $chronos->is_time($exclusive, $object); Return: TYPE description Arguments: TYPE $exclusive: description TYPE $object: description Description: description method is_date($exclusive, $object) Synopsis: $result = $chronos->is_date($exclusive, $object); Return: TYPE description Arguments: TYPE $exclusive: description TYPE $object: description Description: description method is_datetime($object) Synopsis: $result = $chronos->is_datetime($object); Return: TYPE description Arguments: TYPE $object: description Description: description method is_dateOrTime($object) Synopsis: $result = $chronos->is_dateOrTime($object); Return: TYPE description Arguments: TYPE $object: description Description: description method is_difference($object) Synopsis: $result = $chronos->is_difference($object); Return: TYPE description Arguments: TYPE $object: description Description: description method is_leapyear($year) Synopsis: $result = $chronos->is_leapyear($year); Return: TYPE description Arguments: TYPE $year: description Description: description method is_dst() Synopsis: $result = $chronos->is_dst(); Return: TYPE description Description: description method is_equal($to) Synopsis: $result = $chronos->is_equal($to); Return: TYPE description Arguments: TYPE $to: description Description: description method is_biggerOrEqual($than) Synopsis: $result = $chronos->is_biggerOrEqual($than); Return: TYPE description Arguments: TYPE $than: description Description: description method is_bigger($than) Synopsis: $result = $chronos->is_bigger($than); Return: TYPE description Arguments: TYPE $than: description Description: description method is_smallerOrEqual($than) Synopsis: $result = $chronos->is_smallerOrEqual($than); Return: TYPE description Arguments: TYPE $than: description Description: description method is_smaller($than) Synopsis: $result = $chronos->is_smaller($than); Return: TYPE description Arguments: TYPE $than: description Description: description method get_utc($timezone) Synopsis: $result = $chronos->get_utc($timezone); Return: TYPE description Arguments: TYPE $timezone: description Description: description method get_timezone($format) Synopsis: $result = $chronos->get_timezone($format); Return: TYPE description Arguments: TYPE $format: description Description: description method get_string($block, $string) Synopsis: $result = $chronos->get_string($block, $string); Return: TYPE description Arguments: TYPE $block: description TYPE $string: description Description: description method get_comparison($with) Synopsis: $result = $chronos->get_comparison($with); Return: TYPE description Arguments: TYPE $with: description Description: description method get_cmp($with) Synopsis: $result = $chronos->get_cmp($with); Return: TYPE description Arguments: TYPE $with: description Description: description method get_withoutOverflow($array) Synopsis: $result = $chronos->get_withoutOverflow($array); Return: TYPE description Arguments: TYPE $array: description Description: description method get_differenceTo($to, $absolute) Synopsis: $result = $chronos->get_differenceTo($to, $absolute); Return: TYPE description Arguments: TYPE $to: description TYPE $absolute: description Description: description method get_stringPart($part) Synopsis: $result = $chronos->get_stringPart($part); Return: TYPE description Arguments: TYPE $part: description Description: description method get_timeserverStamp($server, $port) Synopsis: $result = $chronos->get_timeserverStamp($server, $port); Return: TYPE description Arguments: TYPE $server: description TYPE $port: description Description: description method get_appliedModificators($value, $modifiers) Synopsis: $result = $chronos->get_appliedModificators($value, $modifiers); Return: TYPE description Arguments: TYPE $value: description TYPE $modifiers: description Description: description method get_sunCalculation($location, $what, $timezone) Synopsis: $result = $chronos->get_sunCalculation($location, $what, $timezone); Return: TYPE description Arguments: TYPE $location: description TYPE $what: description TYPE $timezone: description Description: description method include_exists($filename) Synopsis: $result = $chronos->include_exists($filename); Return: TYPE description Arguments: TYPE $filename: description Description: description method convert_toDifference($ignoreDate) Synopsis: $result = $chronos->convert_toDifference($ignoreDate); Return: TYPE description Arguments: TYPE $ignoreDate: description Description: description method convert_toTime() Synopsis: $result = $chronos->convert_toTime(); Return: TYPE description Description: description method convert_toDate() Synopsis: $result = $chronos->convert_toDate(); Return: TYPE description Description: description method convert_toDatetime($getMissingFrom, $value) Synopsis: $result = $chronos->convert_toDatetime($getMissingFrom, $value); Return: TYPE description Arguments: TYPE $getMissingFrom: description TYPE $value: description Description: description