Class ecdDate

Description

Date and time related functions

Located in /ecdDate.inc.php (line 83)


	
			
Variable Summary
mixed $annee
mixed $heure
mixed $jour
mixed $liste_mois
mixed $mois
Method Summary
ecdDate ecdDate ([string $date = null], [string $type = 'unixtimestamp'])
Array calendar ([mixed $date = null], mixed $firstday)
string calendar_def_callback (string $action, Date $date, string $data)
string calendar_str ([Date $date = null], int $firstday, [function $callback = null])
if checktime (mixed $time)
string datetime ([string $sep = '-'])
Array dayBounds ([int $timestamp = null])
void getLongDate (mixed $lang)
void getShortDate (mixed $lang)
array how_much_time (int $timestamp, [mixed $max = YEARS], [mixed $round = SECONDS])
void how_much_time_str (mixed $timestamp, [mixed $max = YEARS], [mixed $round = SECONDS])
void round_seconds (mixed $timestamp, mixed $round)
void shortTime ()
void time ()
void unixtimestamp ()
void valid ()
Array weekBounds ([int $timestamp = null], int $start_day)
Variables
mixed $annee (line 85)
mixed $heure (line 85)
mixed $jour (line 85)
mixed $liste_mois = array (
1 => array( 'fr' => 'janvier',
'en' => 'january' ),2=>array('fr'=>'février','en'=>'february'),3=>array('fr'=>'mars','en'=>'march'),4=>array('fr'=>'avril','en'=>'april'),5=>array('fr'=>'mai','en'=>'may'),6=>array('fr'=>'juin','en'=>'june'),7=>array('fr'=>'juillet','en'=>'july'),8=>array('fr'=>'août','en'=>'august'),9=>array('fr'=>'septembre','en'=>'september'),10=>array('fr'=>'octobre','en'=>'october'),11=>array('fr'=>'novembre','en'=>'november'),12=>array('fr'=>'décembre','en'=>'december'))
(line 87)
mixed $mois (line 85)
Methods
Constructor ecdDate (line 124)

Create a date object

This creates a date object using the specified timestamp and format.

ecdDate ecdDate ([string $date = null], [string $type = 'unixtimestamp'])
  • string $date: the date to parse
  • string $type: one of 'datetime', 'timestamp' (or 'sqltimestamp') or 'unixtimestamp'
calendar (line 474)

generate a in-memory calendar structure

- the structure is made up like this, taking October 2004 as an example:

Array(Array(null, null, null, null, null, 1, 2) Array(3, 4, 5, 6, 7, 8, 9), Array(10, 11, 12, 13, 14, 15, 16), Array(17, 18, 19, 20, 21, 22, 23), Array(24, 25, 26, 27, 28, 29, 30));

  • return: the list of weeks which are list of days
Array calendar ([mixed $date = null], mixed $firstday)
calendar_def_callback (line 533)

the default callback for the calendar_str

-

  • return: for day_of_week actions, just return $data. for the other actions, returns a link to the current REQUEST_URI with a date parameter added appropriatly in the GET.
  • uses: add_or_replace_get()
string calendar_def_callback (string $action, Date $date, string $data)
  • string $action: one of
    • 'next_month', 'next_year', 'prev_month', 'prev_year': the date controls
    • 'day_of_week': each header
    • 'day': each day
  • Date $date: the "current" date the calendar is generated for
  • string $data: the "default" data displayed. one of:
    • 'next_month': ">"
    • 'next_year': ">>"
    • 'prev_month': "<"
    • 'prev_year': "<<"
    • 'day_of_week': 'di', 'lu', 'ma', 'me', ...
    • 'day': the day number
calendar_str (line 584)

print a calendar in an HTML table

- this uses the calendar() function to generate a calendar based on the given date. the calendar is created in-memor and returned as a string.

generated styles:

  • table.calendar: the main calendar table
  • table.calendar tr.header: the controls and current month/year row
  • table.calendar tr.day_of_week: the list of days row
  • table.calendar tr td.today: today
  • table.calendar tr td.highlight: the date given to calendar_str

  • return: the generated calendar
  • see: calendar_def_callback() for more details on callbacks
string calendar_str ([Date $date = null], int $firstday, [function $callback = null])
  • Date $date: a day for which you want a calendar around
  • int $firstday: the first day of the week (0 = sunday, default).
  • function $callback: a callback that is called to handle the printing of some parts of the calendar. Defaults to array('ecdDate', 'calendar_def_callback').
checktime (line 214)

check validity of a "time" string

  • return: the time string is valid:
    • 1 or 2 ":" in the string
    • hours are between 0 and 23 incl.
    • minutes and seconds are between 0 and 59 incl.
if checktime (mixed $time)
datetime (line 275)

a SQL DATETIME

  • return: a date in the form 2004-010-15 19:24:17, where $sep is '-'
string datetime ([string $sep = '-'])
  • string $sep: the separator
dayBounds (line 419)

generate bounds enclosing the day the $timestamp is in

  • return: a pair of UNIX timestamps delimiting the week, the first timme between Sunday morning (midnight) and the last time being saturday night (midnight)
  • todo: implement without Date or reimplement this whole class as a child of Date (more likely)
  • todo: PHP is buggy on those references: $this might be set to an object other than a ecdDate
Array dayBounds ([int $timestamp = null])
  • int $timestamp: a UNIX timestamp of the time we want to check
getLongDate (line 172)
void getLongDate (mixed $lang)
getShortDate (line 163)
void getShortDate (mixed $lang)
how_much_time (line 321)

Compute how much time this number of seconds represents

This splits the seconds into years, weeks, days, hours, minutes and seconds.

For the purposes of this function, a year is 365 days, which are 24 hours, which are 3600 seconds. This is of course imprecise as the Earth isn't so flat with the seconds humans chose.

  • return:

    an array in the form:

    1. array('year' => $y,
    2. 'week' => $w,
    3. 'day' => $d,
    4. 'hour' => $h,
    5. 'minute' => $m,
    6. 'second' => $s);

    The elements are present only if not zero, except in the case where the time is 0, then the result is Array('second' => 0). Also note negative ranges will be returned as positive values.

array how_much_time (int $timestamp, [mixed $max = YEARS], [mixed $round = SECONDS])
  • int $timestamp: a number of seconds passed
how_much_time_str (line 392)

How much time has passed in readable text.

The time (in years, weeks, days, hours, minutes and seconds) is computed using how_much_time() and returned as a string.

Example:

  1. print how_much_time_str(862150606);

will print the string:

  1. 27 années, 17 semaines, 4 jours, 14 heures, 16 minutes et 46 secondes

void how_much_time_str (mixed $timestamp, [mixed $max = YEARS], [mixed $round = SECONDS])
round_seconds (line 283)
void round_seconds (mixed $timestamp, mixed $round)
shortTime (line 252)

the short time (hours and minutes)

void shortTime ()
time (line 245)

the "time" part of this date

void time ()
unixtimestamp (line 262)

the UNIX timestamp of this date (seconds since epoch)

void unixtimestamp ()
valid (line 227)

check the validity of the given date

void valid ()
weekBounds (line 438)

generate bounds enclosing the week the $timestamp is in

  • return: a pair of UNIX timestamps delimiting the week, the first timme between Sunday morning (midnight) and the last time being saturday night (midnight)
  • todo: implement without Date or reimplement this whole class as a child of Date (more likely)
  • todo: PHP is buggy on those references: $this might be set to an object other than a ecdDate
Array weekBounds ([int $timestamp = null], int $start_day)
  • int $timestamp: a UNIX timestamp of the time we want to check
  • int $start_day: the first day of the week (0,7 = sunday, 1 = monday, etc)

Documentation generated on Tue, 11 Jan 2005 01:38:19 -0500 by phpDocumentor 1.3.0RC3