kernel
[ class tree: kernel ] [ index: kernel ] [ all elements ]

Class: BitDate

Source Location: /kernel/BitDate.php

Class Overview


BitDate


Author(s):

Variables

Methods



Class Details

[line 28]
BitDate

This class takes care of all time/date conversions for storing dates in the DB and displaying dates to the user.

The objectives are:

  • Dates will always stored in UTC in the database
  • Display dates will be computed based on the preferred display offset specified in the constructor




Tags:

todo:  As of 1.7, dates are still stored in server local time. This should be changed for 1.7.1 (requires many module changes).


[ Top ]


Class Variables

$display_offset =

[line 33]

UTC offset to use for display


Type:   int


[ Top ]

$server_offset =

[line 39]

Current UTC offset of server


Type:   int


[ Top ]



Class Methods


static method getHolidays [line 1150]

static an getHolidays( [$pYear $pYear = NULL], [$pCountryCode $pCountryCode = 'US'])

Get a hash of holidays for a given year



Tags:

return:  associative array containing the holidays occuring in the given year they key is a date stamp of the form Y-m-d, the value is the name of the corresponding holiday
access:  public


Parameters:

$pYear   $pYear   the year in question
$pCountryCode   $pCountryCode   -- the country in question - only US is supported currently

[ Top ]

constructor BitDate [line 45]

BitDate BitDate( [int $_display_offset = 0])

Default constructor



Parameters:

int   $_display_offset   desired offset for date display, in minutes

[ Top ]

method calculateTimeZoneDate [line 1206]

void calculateTimeZoneDate( $dateTime, $fromTZ, $toTZ, [ $fromLocation = 'North America'], [ $toLocation = 'GMT'])



Parameters:

   $dateTime  
   $fromTZ  
   $toTZ  
   $fromLocation  
   $toLocation  

[ Top ]

method date [line 590]

string date( string $fmt, [int $d = false], [boolean $is_gmt = false])

Return formatted date based on timestamp $d



Tags:

return:  In the format specified by $fmt


Parameters:

string   $fmt   Format of date output
int   $d   Date to be converted
boolean   $is_gmt   Ignore timezone

[ Top ]

method date2 [line 564]

void date2( $fmt, [ $d = false], [ $is_gmt = false])



Parameters:

   $fmt  
   $d  
   $is_gmt  

[ Top ]

method dayOfWeek [line 224]

int dayOfWeek( int $year, int $month, int $day)

Returns day of week, 0 = Sunday,... 6=Saturday.

Algorithm from PEAR::Date_Calc




Parameters:

int   $year  
int   $month  
int   $day  

[ Top ]

method daysInMonth [line 1117]

void daysInMonth( $month, $year)



Parameters:

   $month  
   $year  

[ Top ]

method getDate [line 341]

array getDate( [boolean $d = false], [boolean $fast = false])

Returns an array with date info.



Parameters:

boolean   $d  
boolean   $fast  

[ Top ]

method getDisplayDateFromUTC [line 90]

int getDisplayDateFromUTC( timestamp $_timestamp)

Convert a UTC timestamp to the preferred display offset.



Tags:

return:  Seconds count based on 1st Jan 1970


Parameters:

timestamp   $_timestamp   ISO format date yYYY-mM-dD hH:mM:sS.s ( Lower case letters optional, but should be 0 )

[ Top ]

method getServerDateFromUTC [line 135]

timestamp getServerDateFromUTC( timestamp $_timestamp)

Convert a UTC timestamp to the local server time.



Tags:

return:  Server timestamp.


Parameters:

timestamp   $_timestamp   UTC timestamp to convert.

[ Top ]

method getTimestampFromISO [line 192]

int getTimestampFromISO( string $iso_date, [ $reverse = false])

Convert ISO date to numberic timestamp.



Tags:

return:  Seconds count based on 1st Jan 1970
returns $iso_date if it is a number, or 0 if format invalid


Parameters:

string   $iso_date   ISO format date yYYY-mM-dD hH:mM:sS.s ( Lower case letters optional, but should be 0 )
   $reverse  

[ Top ]

method getTzName [line 177]

string getTzName( )

Get the name of the current timezone.

Currently, only "UTC" or an empty string (Local).




Tags:

return:  Current timezone


[ Top ]

method getUTCDate [line 168]

string getUTCDate( )

Retrieve a current UTC Date as an ISO formated date



Tags:

return:  Current ISO formated date


[ Top ]

method getUTCFromDisplayDate [line 113]

int getUTCFromDisplayDate( timestamp $_timestamp)

Convert a display-offset timestamp to UTC.



Tags:

return:  Seconds count based on 1st Jan 1970


Parameters:

timestamp   $_timestamp   ISO format date yYYY-mM-dD hH:mM:sS.s ( Lower case letters optional, but should be 0 )

[ Top ]

method getUTCFromServerDate [line 144]

timestamp getUTCFromServerDate( timestamp $_timestamp)

Convert a local server timestamp to UTC.



Tags:

return:  UTC timestamp.


Parameters:

timestamp   $_timestamp   Server timestamp to convert.

[ Top ]

method getUTCTime [line 152]

int getUTCTime( )

Retrieve a current UTC timestamp as Unix epoch.



Tags:

return:  Unix epoch


[ Top ]

method getUTCTimestamp [line 160]

string getUTCTimestamp( )

Retrieve a current UTC Timestamp as an ISO formated date/time.



Tags:

return:  Current ISO formated date/time


[ Top ]

method get_display_offset [line 59]

int get_display_offset( [int $_user = false])

Retrieves the user's preferred offset for displaying dates.



Tags:

return:  the preferred offset to UTC or 0 for straight UTC display


Parameters:

int   $_user   the logged-in user.

[ Top ]

method get_iso8601_datetime [line 1064]

void get_iso8601_datetime( $timestamp, [ $user = false])

Per http://www.w3.org/TR/NOTE-datetime



Parameters:

   $timestamp  
   $user  

[ Top ]

method get_rfc2822_datetime [line 1068]

void get_rfc2822_datetime( [ $timestamp = false], [ $user = false])



Parameters:

   $timestamp  
   $user  

[ Top ]

method get_rfc2822_timezone_offset [line 1085]

void get_rfc2822_timezone_offset( [ $time = false], [ $no_colon = false], [ $user = false])



Parameters:

   $time  
   $no_colon  
   $user  

[ Top ]

method get_timezone_list [line 1038]

void get_timezone_list( [ $use_default = false])

Get a list of timezones to be worked with



Parameters:

   $use_default  

[ Top ]

method gmmktime [line 736]

int gmmktime( int $hr, int $min, int $sec, [int $mon = false], [int $day = false], [int $year = false], [int $is_dst = false])

Returns a timestamp given a GMT/UTC time.



Parameters:

int   $is_dst   is not implemented and is ignored
int   $hr   Hour
int   $min   Minute
int   $sec   Second
int   $mon   Month
int   $day   Day
int   $year   Year

[ Top ]

method gmstrftime [line 855]

void gmstrftime( $fmt, [ $ls = false])



Parameters:

   $fmt  
   $ls  

[ Top ]

method gregorianToISO [line 976]

string gregorianToISO( int $year, int $month, int $day)

Converts from Gregorian Year-Month-Day to ISO YearNumber-WeekNumber-WeekDay

Uses ISO 8601 definitions. Algorithm from Rick McCarty, 1999 at http://personal.ecu.edu/mccartyr/ISOwdALG.txt




Tags:

access:  public


Parameters:

int   $year  
int   $month  
int   $day  

[ Top ]

method is_leap_year [line 300]

boolean is_leap_year( int $year)

checks for leap year, returns true if it is. Has 2-digit year check



Parameters:

int   $year  

[ Top ]

method mktime [line 753]

int mktime( int $hr, int $min, int $sec, [int $mon = false], [int $day = false], [int $year = false], [int $is_dst = false], [ $is_gmt = false])

Return a timestamp given a local time. Originally by jackbbs.

Not a very fast algorithm - O(n) operation. Could be optimized to O(1).




Parameters:

int   $is_dst   is not implemented and is ignored
int   $hr   Hour
int   $min   Minute
int   $sec   Second
int   $mon   Month
int   $day   Day
int   $year   Year
   $is_gmt  

[ Top ]

method set_locale [line 1105]

void set_locale( [ $user = false])



Parameters:

   $user  

[ Top ]

method strftime [line 869]

void strftime( $fmt, [ $ls = false], [ $is_gmt = false])



Parameters:

   $fmt  
   $ls  
   $is_gmt  

[ Top ]

method strtotime [line 860]

void strtotime( $time, [ $now = NULL])



Parameters:

   $time  
   $now  

[ Top ]

method weekOfYear [line 266]

int weekOfYear( int $year, int $month, int $day)

Returns week of year, 1 = first week of year.

Algorithm from PEAR::Date_Calc This needs to be checked out for both start day and early date rules




Parameters:

int   $year  
int   $month  
int   $day  

[ Top ]

method year_digit_check [line 312]

int year_digit_check( int $y)

Fix 2-digit years. Works for any century.

Assumes that if 2-digit is more than 30 years in future, then previous century.




Tags:

todo:  This needs to be disabled when dates prior to 100AD are required in ISO format


Parameters:

int   $y  

[ Top ]

method _getDate [line 381]

array _getDate( [int $origd = false], [boolean $fast = false], [boolean $is_gmt = false])

Low-level function that returns the getdate() array. We have a special $fast flag, which if set to true, will return fewer array values, and is much faster as it does not calculate dow, etc.



Parameters:

int   $origd   Date to be converted in Unix epochs
boolean   $fast   Return short format array ( less weekday and month )
boolean   $is_gmt   Ignore timezone

[ Top ]

method _is_leap_year [line 281]

boolean _is_leap_year( int $year)

Checks for leap year, returns true if it is. No 2-digit year check. Also handles julian calendar correctly.



Parameters:

int   $year  

[ Top ]


Documentation generated on Wed, 29 Jul 2015 13:55:47 +0000 by phpDocumentor 1.5.0-lsces