C# Class Pchp.Library.DateTimeFunctions

Mostrar archivo Open project: iolevel/peachpie

Public Methods

Method Description
checkdate ( int month, int day, int year ) : bool

Returns TRUE if the date given is valid; otherwise returns FALSE. Checks the validity of the date formed by the arguments.

A date is considered valid if: year is between 1 and 32767 inclusive month is between 1 and 12 inclusive day is within the allowed number of days for the given month. Leap years are taken into consideration.

date ( Context ctx, string format ) : string

Returns a string formatted according to the given format string using the current local time.

date ( Context ctx, string format, int timestamp ) : string

Returns a string formatted according to the given format string using the given integer timestamp.

date_sunrise ( Context ctx, int timestamp ) : PhpValue
date_sunrise ( Context ctx, int timestamp, TimeFormats format ) : PhpValue
date_sunrise ( Context ctx, int timestamp, TimeFormats format, double latitude ) : PhpValue
date_sunrise ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude ) : PhpValue
date_sunrise ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith ) : PhpValue
date_sunrise ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset ) : PhpValue
date_sunset ( Context ctx, int timestamp ) : PhpValue
date_sunset ( Context ctx, int timestamp, TimeFormats format ) : PhpValue
date_sunset ( Context ctx, int timestamp, TimeFormats format, double latitude ) : PhpValue
date_sunset ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude ) : PhpValue
date_sunset ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith ) : PhpValue
date_sunset ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset ) : PhpValue
getdate ( Context ctx ) : PhpArray

Returns an associative array containing the date information of the current local time.

getdate ( Context ctx, int timestamp ) : PhpArray

Returns an associative array containing the date information of the timestamp.

gettimeofday ( Context ctx ) : PhpArray

Gets time information.

It returns PhpArray containing the following 4 entries: "sec"Unix timestamp (seconds since the Unix Epoch) "usec"microseconds "minuteswest"minutes west of Greenwich (doesn't take daylight savings time in consideration) "dsttime"type of DST correction (+1 or 0, determined only by the current time zone not by the time)

gettimeofday ( Context ctx, bool returnDouble ) : object
gmdate ( string format ) : string

Identical to the date() function except that the time returned is Greenwich Mean Time (GMT)

gmdate ( string format, int timestamp ) : string

Identical to the date() function except that the time returned is Greenwich Mean Time (GMT)

idate ( Context ctx, string format ) : int

Returns a part of current time.

idate ( Context ctx, string format, int timestamp ) : int

Returns a part of a specified timestamp.

localtime ( Context ctx ) : PhpArray

The localtime() function returns an array identical to that of the structure returned by the C function call. Current time is used, regular numericaly indexed array is returned.

localtime ( Context ctx, int timestamp ) : PhpArray

The localtime() function returns an array identical to that of the structure returned by the C function call. Time specified by the parameter timestamp is used, regular numericaly indexed array is returned.

localtime ( Context ctx, int timestamp, bool returnAssociative ) : PhpArray

The localtime() function returns an array identical to that of the structure returned by the C function call. The first argument to localtime() is the timestamp. The second argument to the localtime() is the isAssociative, if this is set to false than the array is returned as a regular, numerically indexed array. If the argument is set to true then localtime() is an associative array containing all the different elements of the structure returned by the C function call to localtime.

Returned array contains these elements if isAssociative is set to true: "tm_sec"seconds "tm_min"minutes "tm_hour"hour "tm_mday"day of the month "tm_mon"month of the year, starting with 0 for January "tm_year"Years since 1900 "tm_wday"Day of the week "tm_yday"Day of the year "tm_isdst"Is daylight savings time in effect

microtime ( bool returnDouble ) : PhpValue

Returns the fractional time in seconds from the start of the UNIX epoch.

microtime ( ) : string

Returns the string "msec sec" where sec is the current time measured in the number of seconds since the Unix Epoch (0:00:00 January 1, 1970 GMT), and msec is the microseconds part.

strtotime ( string time ) : int

Parses a string containing an English date format into a UNIX timestamp relative to the current time.

strtotime ( string time, int start ) : int

Parses a string containing an English date format into a UNIX timestamp relative to a specified time.

time ( ) : int

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

Private Methods

Method Description
CalculateSunTime ( int day, double latitude, double longitude, double zenith, bool getSunrise ) : double

Calculates sunrise or sunset. Adopted PHP implementation by Moshe Doron ([email protected]). Returns UTC time.

FormatDate ( string format, System.DateTime utc, TimeZoneInfo zone ) : string
GetDate ( Context ctx, System.DateTime utc ) : PhpArray

Returns an associative array containing the date information.

GetDatePart ( char format, System.DateTime utc, TimeZoneInfo zone ) : int
GetDayNumberSuffix ( int DayNumber ) : string

English ordinal suffix for the day of the month, 2 characters - st, nd, rd or th.

GetIsoWeekAndYear ( System.DateTime dt, int &week, int &year ) : void

Converts a given DateTime to the ISO week of year number and ISO year number.

GetLocalTime ( TimeZoneInfo currentTz, System.DateTime utc, bool returnAssociative ) : PhpArray
GetNow ( Context ctx ) : System.DateTime

Gets the current local time with respect to the current PHP time zone.

GetSunTime ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset, bool getSunrise ) : PhpValue
GetSwatchBeat ( System.DateTime utc ) : int
GetTimeOfDay ( System.DateTime utc, TimeZoneInfo zone ) : PhpArray
MakeDateTime ( int hour, int minute, int second, int month, int day, int year ) : System.DateTime
StringToTime ( string time, System.DateTime startUtc ) : int

Implementation of StringToTime(string,int) function.

ToDegrees ( double radians ) : double
ToRadians ( double degrees ) : double

Method Details

checkdate() public static method

Returns TRUE if the date given is valid; otherwise returns FALSE. Checks the validity of the date formed by the arguments.
A date is considered valid if: year is between 1 and 32767 inclusive month is between 1 and 12 inclusive day is within the allowed number of days for the given month. Leap years are taken into consideration.
public static checkdate ( int month, int day, int year ) : bool
month int Month
day int Day
year int Year
return bool

date() public static method

Returns a string formatted according to the given format string using the current local time.
public static date ( Context ctx, string format ) : string
ctx Pchp.Core.Context Current runtime context.
format string Format definition for output.
return string

date() public static method

Returns a string formatted according to the given format string using the given integer timestamp.
public static date ( Context ctx, string format, int timestamp ) : string
ctx Pchp.Core.Context Current runtime context.
format string Format definition for output.
timestamp int Nuber of seconds since 1970 specifying a date.
return string

date_sunrise() public static method

public static date_sunrise ( Context ctx, int timestamp ) : PhpValue
ctx Pchp.Core.Context
timestamp int
return Pchp.Core.PhpValue

date_sunrise() public static method

public static date_sunrise ( Context ctx, int timestamp, TimeFormats format ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
return Pchp.Core.PhpValue

date_sunrise() public static method

public static date_sunrise ( Context ctx, int timestamp, TimeFormats format, double latitude ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
latitude double
return Pchp.Core.PhpValue

date_sunrise() public static method

public static date_sunrise ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
latitude double
longitude double
return Pchp.Core.PhpValue

date_sunrise() public static method

public static date_sunrise ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
latitude double
longitude double
zenith double
return Pchp.Core.PhpValue

date_sunrise() public static method

public static date_sunrise ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
latitude double
longitude double
zenith double
offset double
return Pchp.Core.PhpValue

date_sunset() public static method

public static date_sunset ( Context ctx, int timestamp ) : PhpValue
ctx Pchp.Core.Context
timestamp int
return Pchp.Core.PhpValue

date_sunset() public static method

public static date_sunset ( Context ctx, int timestamp, TimeFormats format ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
return Pchp.Core.PhpValue

date_sunset() public static method

public static date_sunset ( Context ctx, int timestamp, TimeFormats format, double latitude ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
latitude double
return Pchp.Core.PhpValue

date_sunset() public static method

public static date_sunset ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
latitude double
longitude double
return Pchp.Core.PhpValue

date_sunset() public static method

public static date_sunset ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
latitude double
longitude double
zenith double
return Pchp.Core.PhpValue

date_sunset() public static method

public static date_sunset ( Context ctx, int timestamp, TimeFormats format, double latitude, double longitude, double zenith, double offset ) : PhpValue
ctx Pchp.Core.Context
timestamp int
format TimeFormats
latitude double
longitude double
zenith double
offset double
return Pchp.Core.PhpValue

getdate() public static method

Returns an associative array containing the date information of the current local time.
public static getdate ( Context ctx ) : PhpArray
ctx Pchp.Core.Context
return Pchp.Core.PhpArray

getdate() public static method

Returns an associative array containing the date information of the timestamp.
public static getdate ( Context ctx, int timestamp ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
timestamp int Number of seconds since 1970.
return Pchp.Core.PhpArray

gettimeofday() public static method

Gets time information.
It returns PhpArray containing the following 4 entries: "sec"Unix timestamp (seconds since the Unix Epoch) "usec"microseconds "minuteswest"minutes west of Greenwich (doesn't take daylight savings time in consideration) "dsttime"type of DST correction (+1 or 0, determined only by the current time zone not by the time)
public static gettimeofday ( Context ctx ) : PhpArray
ctx Pchp.Core.Context
return Pchp.Core.PhpArray

gettimeofday() public static method

public static gettimeofday ( Context ctx, bool returnDouble ) : object
ctx Pchp.Core.Context
returnDouble bool
return object

gmdate() public static method

Identical to the date() function except that the time returned is Greenwich Mean Time (GMT)
public static gmdate ( string format ) : string
format string Format definition for output.
return string

gmdate() public static method

Identical to the date() function except that the time returned is Greenwich Mean Time (GMT)
public static gmdate ( string format, int timestamp ) : string
format string Format definition for output.
timestamp int Nuber of seconds since 1970 specifying a date.
return string

idate() public static method

Returns a part of current time.
public static idate ( Context ctx, string format ) : int
ctx Pchp.Core.Context Current runtime context.
format string Format definition for output.
return int

idate() public static method

Returns a part of a specified timestamp.
public static idate ( Context ctx, string format, int timestamp ) : int
ctx Pchp.Core.Context Current runtime context.
format string Format definition for output.
timestamp int Nuber of seconds since 1970 specifying a date.
return int

localtime() public static method

The localtime() function returns an array identical to that of the structure returned by the C function call. Current time is used, regular numericaly indexed array is returned.
public static localtime ( Context ctx ) : PhpArray
ctx Pchp.Core.Context
return Pchp.Core.PhpArray

localtime() public static method

The localtime() function returns an array identical to that of the structure returned by the C function call. Time specified by the parameter timestamp is used, regular numericaly indexed array is returned.
public static localtime ( Context ctx, int timestamp ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
timestamp int Number of seconds since 1970.
return Pchp.Core.PhpArray

localtime() public static method

The localtime() function returns an array identical to that of the structure returned by the C function call. The first argument to localtime() is the timestamp. The second argument to the localtime() is the isAssociative, if this is set to false than the array is returned as a regular, numerically indexed array. If the argument is set to true then localtime() is an associative array containing all the different elements of the structure returned by the C function call to localtime.
Returned array contains these elements if isAssociative is set to true: "tm_sec"seconds "tm_min"minutes "tm_hour"hour "tm_mday"day of the month "tm_mon"month of the year, starting with 0 for January "tm_year"Years since 1900 "tm_wday"Day of the week "tm_yday"Day of the year "tm_isdst"Is daylight savings time in effect
public static localtime ( Context ctx, int timestamp, bool returnAssociative ) : PhpArray
ctx Pchp.Core.Context Current runtime context.
timestamp int
returnAssociative bool
return Pchp.Core.PhpArray

microtime() public static method

Returns the fractional time in seconds from the start of the UNIX epoch.
public static microtime ( bool returnDouble ) : PhpValue
returnDouble bool true to return the double, false to return string.
return Pchp.Core.PhpValue

microtime() public static method

Returns the string "msec sec" where sec is the current time measured in the number of seconds since the Unix Epoch (0:00:00 January 1, 1970 GMT), and msec is the microseconds part.
public static microtime ( ) : string
return string

strtotime() public static method

Parses a string containing an English date format into a UNIX timestamp relative to the current time.
public static strtotime ( string time ) : int
time string String containing time definition
return int

strtotime() public static method

Parses a string containing an English date format into a UNIX timestamp relative to a specified time.
public static strtotime ( string time, int start ) : int
time string String containing time definition.
start int Timestamp (seconds from 1970) to which is the new timestamp counted.
return int

time() public static method

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).
public static time ( ) : int
return int