PHP Classes

File: DOCUMENTATION

Recommend this page to a friend!
  Classes of Tommaso DArgenio   KronoClass   DOCUMENTATION   Download  
File: DOCUMENTATION
Role: Documentation
Content type: text/plain
Description: Complete Textual Documentation
Class: KronoClass
A new way to compute time in PHP
Author: By
Last change: Add documentation about new method and some update on old method
Date: 20 years ago
Size: 12,818 bytes
 

Contents

Class file image Download
Krono Object v. $Id class.kronos.php,v 0.7 2003/09/09 16.35.00(CET) marms Exp $ Class for compute some calculations on date and time Related Topics Holosoft Home Page - http://www.holosoft.it KronoClass Home at Author's Site - http://lafucina.holosoft.it/kronoclass/ KronoClass Home at phpclasses - http://www.phpclasses.org/browse.html/package/943.html KronoClass Home at freshmeat - http://freshmeat.net/projects/kronoclass/?topic_id=914 Copyright 2002-2003 Holosoft - Tommaso D'Argenio <rajasi@ziobudda.net> ====================== Properties implemented by Krono ====================== + abbr: Variable for choose long or short day names format + data_from: General purpose use + data_to: General purpose use + date_format: Set to desidered date format + day_name_con: Array that contain the name of days in short format + day_name_ext: Array that contain the name of days in long format + error: Used for errors + lan: Set to desidered language + month_name_con: Array that contain the name of month in short format + month_name_ext: Array that contain the name of month in long format + separator: Char for separating date + time_format: Set to desidered time format + version: Version number ===================== Methods implemented by Krono ===================== + void _check_ini_file() Function that check if ini files for languages exists +void _debug( ) Print out some debug information +void _disclaimer( ) Print out a disclaimer +string _format( ) Return the format string for date function according to date_format parameter and separator +integer _is_daylight( $time) Return if a given time is daylight saving or not Arguments $time Return 1 if time is daylight saving 0 otherwise. +string _language( ) Return the literal name of language code Return The long name of language format +string _update( ) Return the last modified date of class file Return The formatted date of this file last modified field +date atom_date( $date, $atom) Return a single component of given date according to format in date_format date example with hour: 03/05/2003 23:43:00 (use only ':' as time separator) Arguments $date $atom +timestamp date_to_timestamp( date $date) Trasform a classical date format in unix timestamp format. date according to date_format and time_format parameter passed on inizialization Remember that unix timestamp is the amount of seconds since 1/1/1970 Arguments $date The date to transform Return The date transformed in timestamp +integer day_to_n( string $day) Convert the name of a day in its numerical value. + i.e.: Monday stay for 0, Saturday stay for 6 Arguments $day The name of day, short or long. Return the number of day +integer days_diff( date $data_ini, date $data_fin) Define what's the day difference between two given date. + date according to date_format parameter passed on inizialization Arguments $data_ini The start date $data_fin The end date Return The difference in days between the two given dates +void exit_on_error( ) Function that exit with the error message if given +string get_info( string $date, string $what, string $format) Function that give some information on a date + in according with date_format Arguments $date The date to extract info $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 $format [optional, default value = "short"] 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 Return The information asked +date get_nth_day( integer $number, string $weekday, mixed $month, integer $year) Get the date of Nth day of the month .. + example: what is the date of the 2nd Sunday of April 2003 ??? Arguments $number The ordinal value to get date $weekday The name of day given in Long or short format $month the name or number of month $year [optional, default value = 0] the year number Return The date +string get_sun_time( integer $latitude, integer $longitude, integer $timezone, string $location, integer $daylight, string $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 Arguments $latitude [optional, default value = 0] Stay for latitude $longitude [optional, default value = 0] Stay for longitude $timezone [optional, default value = 1] Is the timezone referred to GMT + (ie: for Italy is 1, for Spain is -1 and so on) $location [optional, default value = 'IT|Roma'] If don't know the geographical coordinates of your city give the name of location. (Support only Italian cities, and major Portuguese cities) $daylight [optional, default value = 1] '1' or 'on' if the location use daylight saving time '0' or 'off' if the location doesn't use daylight saving time $date [optional, default value = ''] The date to calc sunset/sunrise on +integer how_days( date $data_ini, date $data_fin, string $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 ? Arguments $data_ini The start date $data_fin The end date $day The name of day for calculating on Return The number of day in the period given +integer how_to( date $data) Define how days left to given date. date according to date_format parameter passed on inizialization Arguments $data The date in traditional format for calculating diff Return The amount of days between today and given date +mixed is_day( date $data, string $day) Define if the day of date given is equal to day given. Is Friday the 22nd of November 2002 ? date according to date_format parameter passed on inizialization Arguments $data The date to check $day The name of day to check Return 1 if check is true, otherwise the day of date +boolean is_valid( string $date) Function that check the validity of a date and/or time in according with date_format and time_format suggested by Vincenzo Visciano < liberodicrederci@yahoo.it > Arguments $date The date and/or time to check validity of Return True if is all ok, False is all wrong, -1 if only date is wrong, -2 if only time is wrong +string k_date( string $format, timestamp $timestamp) Date like function. Using the same format functionality Arguments $format [optional, default value = "%l %d %F %Y"] $timestamp [optional, default value = 0] The time to transform Return The date according with format given +timestamp k_mktime( array $exp) Work like php native mktime() but with date accordingly to format used Arguments $exp The date to transform Return The timestamp calculated on date given +void Krono( string $lan, string $date_format, string $time_format, char $separator) Constructor Arguments $lan [optional, default value = 'it'] The language to use for month/day names $date_format [optional, default value = 'it'] the format for date $time_format [optional, default value = 'it'] $separator [optional, default value = '/'] Character to use as date separator +integer month_to_n( string $month) Convert the name of a month in its numerical value. + i.e.: February stay for 2, December stay for 12 Arguments $month The name of month, short or long format, in language setted by constructor Return The number rappresenting the month +string mysql_time_easy( timestamp $timestamp, string $mode) Transform a MySQL like timestamp to a readable format (and viceversa) + ie: 20011210002745 -> December 10, 2001, 12:27 am Arguments $timestamp The mysql timestamp or date $mode [optional, default value = 'mysqlfrom'] mysqlto (convert a date in readable format to mysql timestamp) Return The timestamp or the date in readable format +string n_to_day( integer $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 Arguments $day The number of day, 0 stay for Sunday and 6 for Saturday Return the name of day in language setted by constructor +string n_to_month( string $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 Arguments $month The number of month Return The name of month in language setted by constructor +timestamp net_timestamp( string $server, integer $port) Return the timestamp from a NIST TIME SERVER on the net. Get the atomic time! attention have to stay on line for work!! Arguments $server [optional, default value = 'time-a.nist.gov'] $port [optional, default value = 37] Return The timestamp from internet +date operation( string $operator, date $date, string $operand) Perform operation like sum or subtraction on date Arguments $operator Operator may be '+' -> for sum 'sum' -> for sum 'add' -> for sum '-' -> for subtraction 'sub'-> for subtraction 'sot'-> for subtraction $date The date to calc on $operand is a number plus '%D' for days, '%M' for months, '%Y' for years Example: Add 1 month to a date: $obj->operation('+','10/01/2003','1%M'); Subtract 20 days from a date: $obj->operation('-','10/01/2003','20%D'); Return The date transformed by calc +pg_time_easy( ) +string roman_date( date $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!!! Arguments $date The date to transform Return The date in roman format +string secs_to_time( integer $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 Arguments $secs number of seconds to be converted to time of day. Return The seconds converted into time +string swatch_time( ) Returns the current time in swatch .beat format. Remember that 1000 beats = 24 hours Return The swatch beat time +string time_to_text( integer $seconds, char $format) Return the literal value of a unix timestamp or seconds + i.e.: so 3670 seconds mean 1 hour, 1 minute and 10 seconds. Arguments $seconds Number of seconds to transform. $format [optional, default value = "h"] 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) Return The seconds transformed in text +string times_add( string $time, integer $add, char $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" Arguments $time The time string to transform $add The hours or minutes to add $what is what add to time "m" -> for add minutes "h" -> for add hours "t" -> for add time string given in HH:mm format Return Result is in format HH:mm, return -1 on error +string times_diff( string $time_from, string $time_to, char $result_in) 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" Arguments $time_from The start time $time_to The end time $result_in [optional, default value = "m"] The format of result "m" -> for minutes "s" -> for seconds "h" -> for hours Return The difference between times according to format given in $result_in +today_moon_phase( string $date) Return the Moon phase for given date, if no date is present refer to present day Arguments $date [optional, default value = ''] +array year_moon_phases( integer $Y) Returns an array with all the phases of the moon for a whole year Arguments $Y is the year to get moon phases. Return The moonphase for each day