Inherits SMWDataItem.
Public Member Functions | |
| __construct ($calendarmodel, $year, $month=false, $day=false, $hour=false, $minute=false, $second=false) | |
| Create a time data item. | |
| getDIType () | |
| Convenience method that returns a constant that defines the concrete class that implements this data item. | |
| getCalendarModel () | |
| getPrecision () | |
| getYear () | |
| getMonth () | |
| getDay () | |
| getHour () | |
| getMinute () | |
| getSecond () | |
| getMwTimestamp ($outputtype=TS_UNIX) | |
| Returns a MW timestamp representatation of the value. | |
| getForCalendarModel ($calendarmodel) | |
| Get the data in the specified calendar model. | |
| getSortKey () | |
| Return a number that helps comparing time data items. | |
| getJD () | |
| getSerialization () | |
| Get a UTF-8 encoded string serialization of this data item. | |
Static Public Member Functions | |
| static | doUnserialize ($serialization) |
| Create a data item from the provided serialization string and type ID. | |
| static | newFromJD ($jdvalue, $calendarmodel, $precision) |
| Create a new time data item from the specified Julian Day number, calendar model, presicion, and type ID. | |
| static | date2JD ($year, $month, $day, $calendarmodel) |
| Compute the Julian Day number from a given date in the specified calendar model. | |
| static | time2JDoffset ($hours, $minutes, $seconds) |
| Compute the offset for the Julian Day number from a given time. | |
| static | JD2Date ($jdvalue, $calendarmodel) |
| Convert a Julian Day number to a date in the given calendar model. | |
| static | JD2Time ($jdvalue) |
| Extract the time from a Julian Day number and return it as a string. | |
| static | isLeapYear ($year, $calendarmodel) |
| Find out whether the given year number is a leap year. | |
| static | getDayNumberForMonth ($month, $year, $calendarmodel) |
| Find out how many days the given month had in the given year based on the specified calendar model. | |
Public Attributes | |
| const | CM_GREGORIAN = 1 |
| const | CM_JULIAN = 2 |
| const | PREC_Y = 0 |
| const | PREC_YM = 1 |
| const | PREC_YMD = 2 |
| const | PREC_YMDT = 3 |
Protected Attributes | |
| $m_precision | |
| $m_model | |
| $m_year | |
| $m_month | |
| $m_day | |
| $m_hours | |
| $m_minutes | |
| $m_seconds | |
Static Protected Attributes | |
| static | $m_daysofmonths = array ( 1 => 31, 2 => 29, 3 => 31, 4 => 30, 5 => 31, 6 => 30, 7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31 ) |
Such data items represent a unique point in time, given in either Julian or Gregorian notation (possibly proleptic), and a precision setting that states which of the components year, month, day, time were specified expicitly. Even when not specified, the data item always assumes default values for the missing parts, so the item really captures one point in time, no intervals. Times are always assumed to be in UTC.
"Y0K issue": Neither the Gregorian nor the Julian calendar assume a year 0, i.e. the year 1 BC(E) was followed by 1 AD/CE. See http://en.wikipedia.org/wiki/Year_zero This implementation adheres to this convention and disallows year 0. The stored year numbers use positive numbers for CE and negative numbers for BCE. This is not just relevant for the question of how many years have (exactly) passed since a given date, but also for the location of leap years.
Definition at line 30 of file SMW_DI_Time.php.
| SMWDITime::__construct | ( | $ | calendarmodel, | |
| $ | year, | |||
| $ | month = false, |
|||
| $ | day = false, |
|||
| $ | hour = false, |
|||
| $ | minute = false, |
|||
| $ | second = false | |||
| ) |
Create a time data item.
All time components other than the year can be false to indicate that they are not specified. This will affect the internal precision setting. The missing values are initialised to minimal values (0 or 1) for internal calculations.
| $calendarmodel | integer one of SMWDITime::CM_GREGORIAN or SMWDITime::CM_JULIAN | |
| $year | integer number of the year (possibly negative) | |
| $month | mixed integer number or false | |
| $day | mixed integer number or false | |
| $hour | mixed integer number or false | |
| $minute | mixed integer number or false | |
| $second | mixed integer number or false |
Definition at line 104 of file SMW_DI_Time.php.
| SMWDITime::getDIType | ( | ) |
Convenience method that returns a constant that defines the concrete class that implements this data item.
Used to switch when processing data items.
Reimplemented from SMWDataItem.
Definition at line 139 of file SMW_DI_Time.php.
References SMWDataItem::TYPE_TIME.
| SMWDITime::getCalendarModel | ( | ) |
Definition at line 143 of file SMW_DI_Time.php.
| SMWDITime::getPrecision | ( | ) |
Definition at line 147 of file SMW_DI_Time.php.
| SMWDITime::getYear | ( | ) |
Definition at line 151 of file SMW_DI_Time.php.
| SMWDITime::getMonth | ( | ) |
Definition at line 155 of file SMW_DI_Time.php.
| SMWDITime::getDay | ( | ) |
Definition at line 159 of file SMW_DI_Time.php.
Referenced by SMWTimeValue::getCaptionFromDataitem().
| SMWDITime::getHour | ( | ) |
Definition at line 163 of file SMW_DI_Time.php.
| SMWDITime::getMinute | ( | ) |
Definition at line 167 of file SMW_DI_Time.php.
| SMWDITime::getSecond | ( | ) |
Definition at line 171 of file SMW_DI_Time.php.
| SMWDITime::getMwTimestamp | ( | $ | outputtype = TS_UNIX |
) |
Returns a MW timestamp representatation of the value.
| $outputtype |
Definition at line 182 of file SMW_DI_Time.php.
| SMWDITime::getForCalendarModel | ( | $ | calendarmodel | ) |
Get the data in the specified calendar model.
This might require conversion.
| $calendarmodel | integer one of SMWDITime::CM_GREGORIAN or SMWDITime::CM_JULIAN |
Definition at line 206 of file SMW_DI_Time.php.
References getJD().
| SMWDITime::getSortKey | ( | ) |
Return a number that helps comparing time data items.
For dates in the Julian Day era (roughly from 4713 BCE onwards), we use the Julian Day number. For earlier dates, the (negative) year number with a fraction for the date is used (times are ignored). This avoids calculation errors that would occur for very ancient dates if the JD number was used there.
Reimplemented from SMWDataItem.
Definition at line 223 of file SMW_DI_Time.php.
References getJD().
| SMWDITime::getJD | ( | ) |
Definition at line 232 of file SMW_DI_Time.php.
Referenced by getForCalendarModel(), and getSortKey().
| SMWDITime::getSerialization | ( | ) |
Get a UTF-8 encoded string serialization of this data item.
The serialisation should be concise and need not be pretty, but it must allow unserialization. Each subclass of SMWDataItem implements a static method doUnserialize() for this purpose.
Reimplemented from SMWDataItem.
Definition at line 237 of file SMW_DI_Time.php.
| static SMWDITime::doUnserialize | ( | $ | serialization | ) | [static] |
Create a data item from the provided serialization string and type ID.
Definition at line 256 of file SMW_DI_Time.php.
| static SMWDITime::newFromJD | ( | $ | jdvalue, | |
| $ | calendarmodel, | |||
| $ | precision | |||
| ) | [static] |
Create a new time data item from the specified Julian Day number, calendar model, presicion, and type ID.
| $jdvalue | double Julian Day number | |
| $calendarmodel | integer either SMWDITime::CM_GREGORIAN or SMWDITime::CM_JULIAN | |
| $precision | integer one of SMWDITime::PREC_Y, SMWDITime::PREC_YM, SMWDITime::PREC_YMD, SMWDITime::PREC_YMDT |
Definition at line 287 of file SMW_DI_Time.php.
Referenced by SMWSetRecurringEvent::jdToTimeValue(), SMWTimeValue::parseUserValue(), and SMWTimeValue::setDateFromParsedValues().
| static SMWDITime::date2JD | ( | $ | year, | |
| $ | month, | |||
| $ | day, | |||
| $ | calendarmodel | |||
| ) | [static] |
Compute the Julian Day number from a given date in the specified calendar model.
This calculation assumes that neither calendar has a year 0.
| $year | integer representing the year | |
| $month | integer representing the month | |
| $day | integer representing the day | |
| $calendarmodel | integer either SMWDITime::CM_GREGORIAN or SMWDITime::CM_JULIAN |
Definition at line 313 of file SMW_DI_Time.php.
| static SMWDITime::time2JDoffset | ( | $ | hours, | |
| $ | minutes, | |||
| $ | seconds | |||
| ) | [static] |
Compute the offset for the Julian Day number from a given time.
This computation is the same for all calendar models.
| $hours | integer representing the hour | |
| $minutes | integer representing the minutes | |
| $seconds | integer representing the seconds |
Definition at line 335 of file SMW_DI_Time.php.
| static SMWDITime::JD2Date | ( | $ | jdvalue, | |
| $ | calendarmodel | |||
| ) | [static] |
Convert a Julian Day number to a date in the given calendar model.
This calculation assumes that neither calendar has a year 0.
| $jdvalue | float number of Julian Days | |
| $calendarmodel | integer either SMWDITime::CM_GREGORIAN or SMWDITime::CM_JULIAN |
Definition at line 349 of file SMW_DI_Time.php.
References $db.
| static SMWDITime::JD2Time | ( | $ | jdvalue | ) | [static] |
Extract the time from a Julian Day number and return it as a string.
This conversion is the same for all calendar models.
| $jdvalue | float number of Julian Days |
Definition at line 388 of file SMW_DI_Time.php.
| static SMWDITime::isLeapYear | ( | $ | year, | |
| $ | calendarmodel | |||
| ) | [static] |
Find out whether the given year number is a leap year.
This calculation assumes that neither calendar has a year 0.
| $year | integer year number | |
| $calendarmodel | integer either SMWDITime::CM_GREGORIAN or SMWDITime::CM_JULIAN |
Definition at line 406 of file SMW_DI_Time.php.
| static SMWDITime::getDayNumberForMonth | ( | $ | month, | |
| $ | year, | |||
| $ | calendarmodel | |||
| ) | [static] |
Find out how many days the given month had in the given year based on the specified calendar model.
This calculation assumes that neither calendar has a year 0.
| $month | integer month number | |
| $year | integer year number | |
| $calendarmodel | integer either SMWDITime::CM_GREGORIAN or SMWDITime::CM_JULIAN |
Definition at line 425 of file SMW_DI_Time.php.
Referenced by SMWTimeValue::getISO8601Date().
| const SMWDITime::CM_GREGORIAN = 1 |
Definition at line 32 of file SMW_DI_Time.php.
Referenced by SMWCompatibilityHelpers::dataItemFromDBKeys(), SMWTimeValue::getCalendarModel(), SMWTimeValue::getDataForCalendarModel(), SMWExporter::getDataItemExpElement(), SMWParseData::getDataItemFromMWTimestamp(), SMWTimeValue::getISO8601Date(), SMWTimeValue::getMediaWikiDate(), SMWTimeValue::getPreferredCaption(), SMWSetRecurringEvent::jdToTimeValue(), and SMWTimeValue::parseUserValue().
| const SMWDITime::CM_JULIAN = 2 |
Definition at line 33 of file SMW_DI_Time.php.
Referenced by SMWTimeValue::getCalendarModel(), SMWTimeValue::getDataForCalendarModel(), and SMWTimeValue::getPreferredCaption().
| const SMWDITime::PREC_Y = 0 |
Definition at line 35 of file SMW_DI_Time.php.
Referenced by SMWTimeValue::getMediaWikiDate(), and SMWTimeValue::setDateFromParsedValues().
| const SMWDITime::PREC_YM = 1 |
Definition at line 36 of file SMW_DI_Time.php.
Referenced by SMWTimeValue::getCaptionFromDataitem(), SMWExporter::getDataItemExpElement(), SMWCompatibilityHelpers::getDBkeysFromDataItem(), and SMWTimeValue::getMonth().
| const SMWDITime::PREC_YMD = 2 |
Definition at line 37 of file SMW_DI_Time.php.
Referenced by SMWTimeValue::getCaptionFromDataitem(), SMWExporter::getDataItemExpElement(), SMWTimeValue::getDay(), SMWCompatibilityHelpers::getDBkeysFromDataItem(), SMWTimeValue::getISO8601Date(), and SMWTimeValue::getMediaWikiDate().
| const SMWDITime::PREC_YMDT = 3 |
Definition at line 38 of file SMW_DI_Time.php.
Referenced by SMWTimeValue::getCaptionFromDataitem(), SMWExporter::getDataItemExpElement(), SMWCompatibilityHelpers::getDBkeysFromDataItem(), SMWTimeValue::getISO8601Date(), SMWTimeValue::getTimeString(), SMWSetRecurringEvent::jdToTimeValue(), and SMWTimeValue::parseUserValue().
SMWDITime::$m_daysofmonths = array ( 1 => 31, 2 => 29, 3 => 31, 4 => 30, 5 => 31, 6 => 30, 7 => 31, 8 => 31, 9 => 30, 10 => 31, 11 => 30, 12 => 31 ) [static, protected] |
Definition at line 44 of file SMW_DI_Time.php.
SMWDITime::$m_precision [protected] |
Definition at line 51 of file SMW_DI_Time.php.
SMWDITime::$m_model [protected] |
Definition at line 56 of file SMW_DI_Time.php.
SMWDITime::$m_year [protected] |
Definition at line 61 of file SMW_DI_Time.php.
SMWDITime::$m_month [protected] |
Definition at line 66 of file SMW_DI_Time.php.
SMWDITime::$m_day [protected] |
Definition at line 71 of file SMW_DI_Time.php.
SMWDITime::$m_hours [protected] |
Definition at line 76 of file SMW_DI_Time.php.
SMWDITime::$m_minutes [protected] |
Definition at line 81 of file SMW_DI_Time.php.
SMWDITime::$m_seconds [protected] |
Definition at line 86 of file SMW_DI_Time.php.
1.5.6