MKrono Class Reference

List of all members.

Public Member Functions

 __construct ($lan='it', $dateFormat='it', $timeFormat='it', $separator='/')
 _checkIniFile ()
 exitOnError ()
 _update ()
 _format ()
 _language ()
 _debug ()
 _disclaimer ()
 _isDaylight ($time)
 dayToN ($day)
 NToDay ($day)
 monthToN ($month)
 NToMonth ($month)
 isDay ($data, $day)
 dateToTimestamp ($date)
 daysDiff ($data_ini, $data_fin)
 timesDiff ($time_from, $time_to, $result_in="m")
 timesAdd ($time, $add, $what)
 howTo ($data)
 howDays ($data_ini, $data_fin, $day)
 kMkTime ($exp)
 atomDate ($date, $atom)
 kDate ($format="%l %d %F %Y", $timestamp=0)
 operation ($operator, $date, $operand)
 netTimestamp ($server='time-a.nist.gov', $port=37)
 swatchTime ()
 mysql_time_easy ($timestamp, $mode='mysqlfrom')
 getNthDay ($number, $weekday, $month, $year=0)
 romanDate ($date)
 yearMoonPhases ($Y)
 todayMoonPhase ($date='')
 getSunTime ($latitude=0, $longitude=0, $timezone=1, $location='IT|Roma', $daylight=1, $date='')
 pg_time_easy ($timestamp)
 timeToText ($seconds, $format="h")
 secsToTime ($secs)
 isValid ($date)
 getInfo ($date, $what, $format="short")
 InvertDate ($date=null)
 CompareDate ($dateA, $operator, $dateB)
 GetDay ($date)
 GetMonth ($date)
 GetYear ($date)
 Between ($date1, $date, $date2)
 makeTime ()

Public Attributes

 $dayNameExt
 $dayNameCon
 $monthNameExt
 $monthNameCon
 $dataFrom
 $dataTo
 $error
 $abbr
 $lan
 $version = '0.7'
 $dateFormat
 $timeFormat
 $separator
 $path

Detailed Description

Class for compute some calculations on date and time

2002-2003 Holosoft - Tommaso D'Argenio <rajasi@ziobudda.net>

Version:
$Id class.kronos.php,v 0.7 2003/09/09 16.35.00(CET) marms Exp $ Holosoft Home Page http://lafucina.holosoft.it/kronoclass/ KronoClass Home at Author's Site http://www.phpclasses.org/browse.html/package/943.html KronoClass Home at phpclasses http://freshmeat.net/projects/kronoclass/?topic_id=914 KronoClass Home at freshmeat

Definition at line 48 of file mkrono.class.


Constructor & Destructor Documentation

MKrono::__construct ( lan = 'it',
dateFormat = 'it',
timeFormat = 'it',
separator = '/' 
)

Constructor public

See also:
Krono::$dateFormat
Parameters:
string $lan The language to use for month/day names
string $dateFormat the format for date
char $separator Character to use as date separator
Returns:
void

Definition at line 137 of file mkrono.class.

References _checkIniFile().

Here is the call graph for this function:


Member Function Documentation

MKrono::_checkIniFile (  ) 

Function that check if ini files for languages exists private void

Definition at line 175 of file mkrono.class.

References exitOnError().

Referenced by __construct().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::exitOnError (  ) 

Function that exit with the error message if given private

Returns:
void

Definition at line 194 of file mkrono.class.

Referenced by _checkIniFile(), _format(), atomDate(), dayToN(), getInfo(), getNthDay(), getSunTime(), howTo(), isValid(), kMkTime(), monthToN(), netTimestamp(), NToDay(), NToMonth(), operation(), timesAdd(), and timesDiff().

Here is the caller graph for this function:

MKrono::_update (  ) 

Return the last modified date of class file private

Returns:
string The formatted date of this file last modified field

Definition at line 207 of file mkrono.class.

References kDate().

Here is the call graph for this function:

MKrono::_format (  ) 

Return the format string for date function according to dateFormat parameter and separator private

Returns:
string

Definition at line 217 of file mkrono.class.

References exitOnError().

Referenced by getNthDay(), howDays(), mysql_time_easy(), and operation().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::_language (  ) 

Return the literal name of language code private

Returns:
string The long name of language format

Definition at line 250 of file mkrono.class.

MKrono::_debug (  ) 

Print out some debug information : private

Returns:
void

Definition at line 273 of file mkrono.class.

MKrono::_disclaimer (  ) 

Print out a disclaimer private

Returns:
void

Definition at line 286 of file mkrono.class.

MKrono::_isDaylight ( time  ) 

Return if a given time is daylight saving or not private

Returns:
int 1 if time is daylight saving 0 otherwise.

Definition at line 298 of file mkrono.class.

Referenced by getSunTime().

Here is the caller graph for this function:

MKrono::dayToN ( day  ) 

Convert the name of a day in its numerical value. + i.e.: Monday stay for 0, Saturday stay for 6 public

Parameters:
string $day The name of day, short or long.
Returns:
int the number of day

Definition at line 345 of file mkrono.class.

References exitOnError().

Referenced by isDay().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::NToDay ( day  ) 

Convert the numerical value of a day in its name for the setted language by constructor. + Short o long format is choosed by setting the abbr value to true o false public

Parameters:
int $day The number of day, 0 stay for Sunday and 6 for Saturday
Returns:
string the name of day in language setted by constructor

Definition at line 372 of file mkrono.class.

References exitOnError().

Referenced by getInfo(), isDay(), and kDate().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::monthToN ( month  ) 

Convert the name of a month in its numerical value. + i.e.: February stay for 2, December stay for 12 public

Parameters:
string $month The name of month, short or long format, in language setted by constructor
Returns:
int The number rappresenting the month

Definition at line 392 of file mkrono.class.

References exitOnError().

Referenced by getNthDay().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::NToMonth ( month  ) 

Convert the numerical value of a month in its name. + Short o long format is choosed by setting the abbr value to true o false public

Parameters:
string $month The number of month
Returns:
string The name of month in language setted by constructor

Definition at line 421 of file mkrono.class.

References exitOnError().

Referenced by getInfo(), and kDate().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::isDay ( data,
day 
)

Define if the day of date given is equal to day given. + Is Friday the 22nd of November 2002 ? + date according to dateFormat parameter passed on inizialization public

Parameters:
date $data The date to check
string $day The name of day to check
Returns:
mixed 1 if check is true, otherwise the day of date

Definition at line 444 of file mkrono.class.

References dayToN(), kMkTime(), and NToDay().

Referenced by howDays().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::dateToTimestamp ( date  ) 

Trasform a classical date format in unix timestamp format. + date according to dateFormat and timeFormat parameter passed on inizialization + Remember that unix timestamp is the amount of seconds since 1/1/1970 public

Parameters:
date $date The date to transform
Returns:
timestamp The date transformed in timestamp

Definition at line 471 of file mkrono.class.

References kMkTime().

Referenced by getInfo(), getSunTime(), operation(), and todayMoonPhase().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::daysDiff ( data_ini,
data_fin 
)

Define what's the day difference between two given date. + date according to dateFormat parameter passed on inizialization public

Parameters:
date $data_ini The start date
date $data_fin The end date
Returns:
int The difference in days between the two given dates

Definition at line 500 of file mkrono.class.

References kMkTime().

Referenced by howDays().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::timesDiff ( time_from,
time_to,
result_in = "m" 
)

Give the difference between two times. + (i.e.: how minutes from 4.50 to 12.50?). + Accept only 24H format. + the time is a string like: "4.50" or "4:50" public

Parameters:
string $time_from The start time
string $time_to The end time
char $result_in The format of result + "m" -> for minutes + "s" -> for seconds + "h" -> for hours
Returns:
string The difference between times according to format given in $result_in

Definition at line 531 of file mkrono.class.

References exitOnError().

Here is the call graph for this function:

MKrono::timesAdd ( time,
add,
what 
)

Add some minutes or hours to a given time. + i.e.: (add 2 hours to 14.10 -> result is 16.10) + Accept only 24H format. + the time is a string like: "4.50" or "4:50"

Parameters:
string $time The time string to transform
int $add The hours or minutes to add
char $what is what add to time + "m" -> for add minutes + "h" -> for add hours + "t" -> for add time string given in HH:mm format
Returns:
string Result is in format HH:mm, return -1 on error

Definition at line 593 of file mkrono.class.

References exitOnError().

Here is the call graph for this function:

MKrono::howTo ( data  ) 

Define how days left to given date. date according to dateFormat parameter passed on inizialization public

Parameters:
date $data The date in traditional format for calculating diff
Returns:
int The amount of days between today and given date

Definition at line 670 of file mkrono.class.

References exitOnError(), and kMkTime().

Here is the call graph for this function:

MKrono::howDays ( data_ini,
data_fin,
day 
)

Define how many days (give it in name format) are in period given. + i.e.: How friday are from Nov,1 2002 to Mar,23 2003 ? public

Parameters:
date $data_ini The start date
date $data_fin The end date
string $day The name of day for calculating on
Returns:
int The number of day in the period given

Definition at line 694 of file mkrono.class.

References _format(), atomDate(), daysDiff(), and isDay().

Here is the call graph for this function:

MKrono::kMkTime ( exp  ) 

Work like php native mktime() but with date accordingly to format used private

Parameters:
array $exp The date to transform
Returns:
timestamp The timestamp calculated on date given

Definition at line 721 of file mkrono.class.

References exitOnError(), and makeTime().

Referenced by dateToTimestamp(), daysDiff(), howTo(), isDay(), and operation().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::atomDate ( date,
atom 
)

Return a single component of given date according to format in dateFormat date example with hour: 03/05/2003 23:43:00 (use only ':' as time separator) public

Returns:
date
Parameters:
date to extract atom from
atom -> + 'm' for return month; + 'd' for return day; + 'y' for return last two number of year + 'Y' for return entire year + 'h' for hours + 'i' for minutes + 's' for seconds

Definition at line 752 of file mkrono.class.

References exitOnError().

Referenced by getInfo(), howDays(), mysql_time_easy(), and romanDate().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::kDate ( format = "%l %d %F %Y",
timestamp = 0 
)

Date like function. Using the same format functionality public

Returns:
string The date according with format given
Parameters:
string format -> + valid format parameter: + l (L lowercase): Day textual long + d: Day of month, 2 digits with leading zeros + F: Month textual Long + Y: Year, 4 digits + y: Year, 2 digits + m: Month numeric, 2 digits with leading zeros + D: Day textual short + M: Month textual short + n: Month numeric, without leading zeros + j: Day of month, without leading zeros
timestamp $timestamp The time to transform

Definition at line 833 of file mkrono.class.

References NToDay(), and NToMonth().

Referenced by _update(), getNthDay(), mysql_time_easy(), pg_time_easy(), and todayMoonPhase().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::operation ( operator,
date,
operand 
)

Definition at line 902 of file mkrono.class.

References _format(), dateToTimestamp(), exitOnError(), and kMkTime().

Referenced by todayMoonPhase().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::netTimestamp ( server = 'time-a.nist.gov',
port = 37 
)

Return the timestamp from a NIST TIME SERVER on the net. Get the atomic time! + attention + have to stay on line for work!! public

Returns:
timestamp The timestamp from internet

Definition at line 996 of file mkrono.class.

References exitOnError().

Here is the call graph for this function:

MKrono::swatchTime (  ) 

Returns the current time in swatch .beat format. Remember that 1000 beats = 24 hours public

Returns:
string The swatch beat time

Definition at line 1018 of file mkrono.class.

MKrono::mysql_time_easy ( timestamp,
mode = 'mysqlfrom' 
)

Transform a MySQL like timestamp to a readable format (and viceversa) + ie: 20011210002745 -> December 10, 2001, 12:27 am public

Returns:
string The timestamp or the date in readable format
Parameters:
timestamp $timestamp The mysql timestamp or date
string $mode mysqlfrom (convert mysql timestamp to readable format)
string $mode mysqlto (convert a date in readable format to mysql timestamp)

Definition at line 1043 of file mkrono.class.

References _format(), atomDate(), and kDate().

Here is the call graph for this function:

MKrono::getNthDay ( number,
weekday,
month,
year = 0 
)

Get the date of Nth day of the month .. + example: what is the date of the 2nd Sunday of April 2003 ??? public

Returns:
date The date
Parameters:
int $number The ordinal value to get date
string $weekday The name of day given in Long or short format
mixed $month the name or number of month
int $year the year number

Definition at line 1085 of file mkrono.class.

References _format(), exitOnError(), kDate(), and monthToN().

Here is the call graph for this function:

MKrono::romanDate ( date  ) 

Return the date in ancient roman date format + note: the date is output in the form: ddmmyyyy without separator.Support maximum to 5000 years!!! public

Returns:
string The date in roman format
Parameters:
date $date The date to transform

Definition at line 1153 of file mkrono.class.

References atomDate().

Here is the call graph for this function:

MKrono::yearMoonPhases ( Y  ) 

Returns an array with all the phases of the moon for a whole year public

Parameters:
int $Y is the year to get moon phases.
Returns:
array The moonphase for each day

Definition at line 1198 of file mkrono.class.

Referenced by todayMoonPhase().

Here is the caller graph for this function:

MKrono::todayMoonPhase ( date = ''  ) 

Definition at line 1283 of file mkrono.class.

References dateToTimestamp(), kDate(), operation(), and yearMoonPhases().

Here is the call graph for this function:

MKrono::getSunTime ( latitude = 0,
longitude = 0,
timezone = 1,
location = 'IT|Roma',
daylight = 1,
date = '' 
)

Return the sunset or sunrise for the given date and geo location. + note: the method called without parameter return the sunrise and sunset of Rome (Italy) with daylight actived public

Returns:
string
Parameters:
int $latitude Stay for latitude
int $longitude Stay for longitude
int $timezone Is the timezone referred to GMT + (ie: for Italy is 1, for Spain is -1 and so on)
string $location If don't know the geographical coordinates of your city give the name of location. (Support only Italian cities)
int $daylight + '1' or 'on' if the location use daylight saving time + '0' or 'off' if the location doesn't use daylight saving time
string $date The date to calc sunset/sunrise on

Definition at line 1320 of file mkrono.class.

References _isDaylight(), dateToTimestamp(), and exitOnError().

Here is the call graph for this function:

MKrono::pg_time_easy ( timestamp  ) 

Definition at line 1486 of file mkrono.class.

References kDate().

Here is the call graph for this function:

MKrono::timeToText ( seconds,
format = "h" 
)

Return the literal value of a unix timestamp or seconds + i.e.: so 3670 seconds mean 1 hour, 1 minute and 10 seconds.

Parameters:
int $seconds Number of seconds to transform.
char $format The format of output, +"h" for hours.minutes.seconds (short form) +"d" for year.months.days.etc (short form) +"H" for hours.minutes.seconds (long form) +"D" for year.months.days.etc (long form) public
Returns:
string The seconds transformed in text

Definition at line 1509 of file mkrono.class.

MKrono::secsToTime ( secs  ) 

Function to turn seconds into a time + added by tim@trundlie.fsnet.co.uk on 08/21/2003 + i.e. 30600sec is 8.30am + 63000sec is 17:30 public

Parameters:
int $secs number of seconds to be converted to time of day.
Returns:
string The seconds converted into time

Definition at line 1609 of file mkrono.class.

MKrono::isValid ( date  ) 

Function that check the validity of a date and/or time + in according with dateFormat and timeFormat + suggested by Vincenzo Visciano <liberodicrederci@yahoo.it> public

Parameters:
string $date The date and/or time to check validity of
Returns:
bool True if is all ok, False is all wrong, -1 if only date is wrong, -2 if only time is wrong

Definition at line 1638 of file mkrono.class.

References exitOnError().

Referenced by getInfo().

Here is the call graph for this function:

Here is the caller graph for this function:

MKrono::getInfo ( date,
what,
format = "short" 
)

Function that give some information on a date + in according with dateFormat public

Parameters:
string $date The date to extract info
string $what What info to extract from date given (in any case) + "monthname" give the name of month + "dayname" give the name of day + "dayofweek" give the ordinal number of day in the week (1 for Sunday, 1 for Monday, and so on) + "dayofyear" give the ordinal number of day in the year + "week" give the number of week in the year + "trimester" give the number of trimester in the year
string $format For textual information, specify if out in the short or long format +"short" or "s" for the short format (default) +"long" or "l" for the long format
Returns:
string The information asked

Definition at line 1739 of file mkrono.class.

References atomDate(), dateToTimestamp(), exitOnError(), isValid(), NToDay(), and NToMonth().

Here is the call graph for this function:

MKrono::InvertDate ( date = null  ) 

Definition at line 1796 of file mkrono.class.

Referenced by Between().

Here is the caller graph for this function:

MKrono::CompareDate ( dateA,
operator,
dateB 
)

Definition at line 1806 of file mkrono.class.

MKrono::GetDay ( date  ) 

Definition at line 1840 of file mkrono.class.

MKrono::GetMonth ( date  ) 

Definition at line 1846 of file mkrono.class.

MKrono::GetYear ( date  ) 

Definition at line 1852 of file mkrono.class.

MKrono::Between ( date1,
date,
date2 
)

Definition at line 1858 of file mkrono.class.

References InvertDate().

Here is the call graph for this function:

MKrono::makeTime (  ) 

Definition at line 1869 of file mkrono.class.

Referenced by kMkTime().

Here is the caller graph for this function:


Member Data Documentation

MKrono::$dayNameExt

Array that contain the name of days in long format * private

Definition at line 53 of file mkrono.class.

MKrono::$dayNameCon

Array that contain the name of days in short format private

Definition at line 58 of file mkrono.class.

MKrono::$monthNameExt

Array that contain the name of month in long format private

Definition at line 63 of file mkrono.class.

MKrono::$monthNameCon

Array that contain the name of month in short format private

Definition at line 68 of file mkrono.class.

MKrono::$dataFrom

General purpose use private

Definition at line 73 of file mkrono.class.

MKrono::$dataTo

General purpose use private

Definition at line 78 of file mkrono.class.

MKrono::$error

Used for errors private

Definition at line 83 of file mkrono.class.

MKrono::$abbr

Variable for choose long or short day names format public

Definition at line 88 of file mkrono.class.

MKrono::$lan

Set to desidered language public

Definition at line 93 of file mkrono.class.

MKrono::$version = '0.7'

Version number private

Definition at line 98 of file mkrono.class.

MKrono::$dateFormat

Set to desidered date format public + possible values: + it -> italian (dd-mm-yyyy) + en,std -> international (mm-dd-yyyy) + ansi -> used in dbase and other source (yyyy-mm-dd)

Definition at line 108 of file mkrono.class.

MKrono::$timeFormat

Set to desidered time format public + possible values: + 24,it -> italian format 24H ie: 20.17, 9.11 + 12,en -> international 12H ie: 8.17PM, 9.11AM

Definition at line 117 of file mkrono.class.

MKrono::$separator

Char for separating date public

Definition at line 122 of file mkrono.class.

MKrono::$path

Char for path of ini files public

Definition at line 127 of file mkrono.class.


The documentation for this class was generated from the following file:
CopyLeft (L) 2001-2006 - [MIOLO Development Team] SOLIS - Cooperativa de Soluções Livres - Lajeado/RS - Brasil