Qore Programming Language Reference Manual  0.8.11.1
Date and Time Functions

Functions

int Qore::clock_getmicros ()
 Returns an integer representing the system time in microseconds (1/1000000 second intervals) since Jan 1, 1970 00:00:00Z. More...
 
int Qore::clock_getmillis ()
 Returns an integer representing the system time in milliseconds (1/1000 second intervals since Jan 1, 1970 00:00) More...
 
int Qore::clock_getnanos ()
 Returns an integer representing the system time in nanoseconds (1/1000000000 second intervals) since Jan 1, 1970 00:00:00Z. More...
 
date Qore::date (date dt)
 Returns the date passed. More...
 
date Qore::date (string dtstr)
 Converts the argument to a date and returns the date. More...
 
date Qore::date (float f)
 The argument is assumed to be the number of seconds and fractions of a second since 1970-01-01 in the local time zone; this value is used to produce the date value that is returned. More...
 
date Qore::date (softint i)
 The argument is assumed to be the number of seconds since 1970-01-01 in the local time zone; this value is used to produce the date value that is returned. More...
 
date Qore::date ()
 This function just returns 1970-01-01Z. More...
 
date Qore::date (null null)
 This function just returns 1970-01-01Z. More...
 
date Qore::date (string dtstr, string mask)
 Returns the date/time value corresponding to parsing a string argument according to a format mask. More...
 
hash Qore::date_info (date dt)
 Returns a hash of broken-down date/time information for the given date argument (can be either a relative or absolute date) More...
 
hash Qore::date_info ()
 Returns a hash of broken-down date/time information for the current date and time. More...
 
date Qore::date_ms (softint ms)
 Converts an integer argument representing the offset in milliseconds from January 1, 1970 in the local time zone to a date in the local time zone. More...
 
nothing Qore::date_ms ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
date Qore::date_us (softint us)
 Converts an integer argument representing the offset in microseconds from January 1, 1970 in the local time zone to a date in the local time zone. More...
 
date Qore::days (softint days)
 Returns a relative date/time value in days based on the integer argument passed to be used in date arithmetic. More...
 
nothing Qore::days ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::format_date (string format, date dt)
 Returns a formatted string for a date argument passed. More...
 
nothing Qore::format_date ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
date Qore::getDateFromISOWeek (softint year, softint week, softint day=1)
 Retuns an absolute date value for the ISO-8601 calendar week information passed (year, week number, optional: weekday, where 1=Monday, 7=Sunday) in the current time zone. More...
 
int Qore::getDayNumber (date dt)
 Returns an integer representing the ordinal day number in the year (corresponding to the ISO-8601 day number) for the absolute date value passed. More...
 
nothing Qore::getDayNumber ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::getDayOfWeek (date dt)
 Returns an integer representing the day of the week for the absolute date value passed (0=Sunday, 6=Saturday) More...
 
nothing Qore::getDayOfWeek ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::getISODayOfWeek (date dt)
 Returns an integer representing the ISO-8601 day of the week for the absolute date value passed (1=Monday, 7=Sunday) More...
 
nothing Qore::getISODayOfWeek ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
hash Qore::getISOWeekHash (date dt)
 Returns a hash representing the ISO-8601 calendar week information for the absolute date passed (hash keys: "year", "week", "day") More...
 
nothing Qore::getISOWeekHash ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
string Qore::getISOWeekString (date dt)
 Returns a string representing the ISO-8601 calendar week information for the absolute date passed (ex: 2006-01-01 = "2005-W52-7") More...
 
nothing Qore::getISOWeekString ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_days (date dt)
 Returns an integer corresponding to the literal day value in the date (does not calculate a duration) More...
 
nothing Qore::get_days ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_duration_microseconds (date dt)
 Returns an integer value representing the the number of microseconds of duration in the value of the date passed (can be either a relative or absolute date) More...
 
int Qore::get_duration_milliseconds (date dt)
 Returns an integer value representing the the number of milliseconds of duration in the value of the date passed (can be either a relative or absolute date) More...
 
int Qore::get_duration_seconds (date dt)
 Returns an integer value representing the the number of seconds of duration in the value of the date passed (can be either a relative or absolute date) More...
 
int Qore::get_epoch_seconds (date dt)
 Returns the number of seconds of the date and time in local time passed since Jan 1, 1970, 00:00:00 Z (UTC); negative values are returned for dates before the epoch. More...
 
nothing Qore::get_epoch_seconds ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_hours (date dt)
 Returns an integer corresponding to the literal hour value in the date (does not calculate a duration) More...
 
nothing Qore::get_hours ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_microseconds (date dt)
 Returns an integer corresponding to the literal microsecond value in the date (does not calculate a duration) More...
 
date Qore::get_midnight (date dt)
 Returns midnight on the date passed (strips the time component on the new value) More...
 
nothing Qore::get_midnight ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_milliseconds (date dt)
 Returns an integer corresponding to the literal millisecond value in the date (does not calculate a duration) More...
 
nothing Qore::get_milliseconds ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_minutes (date dt)
 Returns an integer corresponding to the literal minute value in the date (does not calculate a duration) More...
 
nothing Qore::get_minutes ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_months (date dt)
 Returns an integer corresponding to the literal month value in the date (does not calculate a duration) More...
 
nothing Qore::get_months ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_seconds (date dt)
 Returns an integer corresponding to the literal second value in the date (does not calculate a duration) More...
 
nothing Qore::get_seconds ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::get_years (date dt)
 Returns an integer corresponding to the literal year value in the date (does not calculate a duration) More...
 
nothing Qore::get_years ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
date Qore::gmtime ()
 Returns the current UTC (GMT) time with a resolution of a second. More...
 
date Qore::gmtime (softint secs, softint us=0)
 Returns a date/time value in UTC (GMT) from arguments giving the number of seconds and microseconds since Jan 1, 1970, 00:00:00 Z (UTC) More...
 
date Qore::gmtime (date dt)
 Returns the date and time in UTC (GMT) corresponding to the date argument passed. More...
 
date Qore::hours (softint hours)
 Returns a relative date/time value in hours based on the integer argument passed to be used in date arithmetic. More...
 
nothing Qore::hours ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
bool Qore::is_date_absolute (date dt)
 Returns True if the argument is an absolute date/time value, False if not. More...
 
bool Qore::is_date_absolute ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
bool Qore::is_date_relative (date dt)
 Returns True if the argument is an relative date/time value, False if not. More...
 
bool Qore::is_date_relative ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
date Qore::localtime ()
 Returns the current date and time with a resolution to the second. More...
 
date Qore::localtime (softint secs, softint us=0)
 Returns the date and time in the local time zone corresponding to the integer arguments passed, which are interpreted as the number of seconds and microseconds since Jan 1, 1970, 00:00:00 Z (UTC) More...
 
date Qore::localtime (date dt)
 Returns the date and time in the local time zone corresponding to the date argument passed. More...
 
date Qore::microseconds (softint us)
 Returns a relative date/time value in microseconds based on the integer argument passed to be used in date arithmetic. More...
 
date Qore::milliseconds (softint ms)
 Returns a relative date/time value in milliseconds based on the integer argument passed to be used in date arithmetic. More...
 
nothing Qore::milliseconds ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
date Qore::minutes (softint minutes)
 Returns a relative date/time value in minutes based on the integer argument passed to be used in date arithmetic. More...
 
nothing Qore::minutes ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::mktime (date dt)
 Returns the number of seconds of the date and time in local time passed since Jan 1, 1970, 00:00:00 Z (UTC); negative values are returned for dates before the epoch. More...
 
nothing Qore::mktime ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
date Qore::months (softint months)
 Returns a relative date/time value in months based on the integer argument passed to be used in date arithmetic. More...
 
nothing Qore::months ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
date Qore::now ()
 Returns the current date and time with a resolution to the second. More...
 
date Qore::now_ms ()
 Returns the current date and time with a resolution to the millisecond. More...
 
date Qore::now_us ()
 Returns the current date and time with a resolution to the microsecond. More...
 
date Qore::now_utc ()
 Returns the current UTC date and time with a resolution to the microsecond. More...
 
date Qore::seconds (softint seconds)
 Returns a relative date/time value in seconds based on the integer argument passed to be used in date arithmetic. More...
 
nothing Qore::seconds ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
int Qore::timegm (date dt)
 Returns the number of seconds since January 1, 1970 00:00:00 in the local time zone for the given date. More...
 
nothing Qore::timegm ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 
date Qore::years (softint years)
 Returns a relative date/time value in years based on the integer argument passed to be used in date arithmetic. More...
 
nothing Qore::years ()
 This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments. More...
 

Detailed Description

Date Formatting Codes

Format Code Description
YY last two digits of year
YYYY four-digit year
M non zero-padded month number (1-12)
MM zero-padded two-digit month number (01-12)
Month long month string (ex: "January")
MONTH long month string capitalized (ex: "JANUARY")
Mon abbreviated month (ex: "Jan")
MON abbreviated month, capitalized (ex: "JAN")
D non zero-padded day number (1 - 31)
DD zero-padded day number (01 - 31)
Day long day of week string (ex: "Monday")
DAY long day of week string, capitalized (ex: "MONDAY")
Dy abbreviated day of week string (ex: "Mon")
DY abbreviated day of week string capitalized (ex: "MON")
H non zero-padded hour number (0 - 23)
HH zero-padded hour number (00 - 23)
h non zero-padded hour number, 12-hour clock (1 - 12)
hh zero-padded hour number, 12-hour clock (01 - 12)
m non zero-padded minute number (0 - 59)
mm zero-padded minute number (00 - 59)
S non zero-padded second number (0 - 59)
SS zero-padded second number (00 - 59)
P "AM" or "PM" (upper-case)
p "am" or "pm" (lower-case)
u non zero-padded millisecond number (0 - 999)
uu or ms zero-padded millisecond number (000 - 999)
x non zero-padded microsecond number (0 - 999999)
xx or us zero-padded microsecond number (000000 - 999999)
y microseconds, with trailing zeros removed (suitable for use after the '.')
z local time zone name (ex: "EST") if available, otherwise the UTC offset (ex: "+01:00")
Z time zone UTC offset like +HH:mm[:SS] (ex: "+01:00"), seconds are only included if non-zero
Since
"us" was added in Qore 0.8.7
Bug:
the "u" and "uu" format codes work with milliseconds and not microseconds since they were implemented before qore supported microsecond time resolution; this cannot be changed without breaking backwards-compatibility

Date/Time Information Hash

Key Type Absolute/Relative Description
relative bool Both True if the date is a relative date, False if it is absolute
year int Both The year value of the date
month int Both The month value of the date
day int Both The day value of the date (day of the month for absolute dates)
hour int Both The hour value of the date
minute int Both The minute value of the date
second int Both The second value of the date
microsecond int Both The microsecond value of the date
dow int Absolute Only The day of the week, where 0=Sunday, 1=Monday, ... 6=Saturday
doy int Absolute Only The ordinal day number in the year
utc_secs_east int Absolute Only Offset from UTC in seconds east; if the time zone is west of UTC then the value will be negative
dst bool Absolute Only A flag if daylight savings time is in effect
zone TimeZone Absolute Only The time zone for the time
zone_name string Absolute Only The name of the time zone for the given time (ex: "CEST" for Central European Summer Time for a time during summer time or "CET" for Central European Time for the same time zone while daylight savings time is not active)

Date Mask Format

The date mask (as used in Qore::date(string, string) and Qore::TimeZone::date(string, string)) is used to specify the string format of a date/time value for parsing to a date/time value.

The fields in the mask string are as follows:

Bug:
currently only English month abbreviations are accepted in the date/time mask

Function Documentation

int Qore::clock_getmicros ( )

Returns an integer representing the system time in microseconds (1/1000000 second intervals) since Jan 1, 1970 00:00:00Z.

Returns
an integer representing the system time in microseconds (1/1000000 second intervals) since Jan 1, 1970 00:00:00Z
Code Flags:
CONSTANT
Example:
my int $us = clock_getmicros();
See also
int Qore::clock_getmillis ( )

Returns an integer representing the system time in milliseconds (1/1000 second intervals since Jan 1, 1970 00:00)

Returns
an integer representing the system time in milliseconds (1/1000 second intervals since Jan 1, 1970 00:00)
Code Flags:
CONSTANT
Example:
my int $ms = clock_getmillis();
See also
int Qore::clock_getnanos ( )

Returns an integer representing the system time in nanoseconds (1/1000000000 second intervals) since Jan 1, 1970 00:00:00Z.

Returns
an integer representing the system time in nanoseconds (1/1000000000 second intervals) since Jan 1, 1970 00:00:00Z
Code Flags:
CONSTANT
Example:
my int $ns = clock_getnanos();
See also
date Qore::date ( date  dt)

Returns the date passed.

This function is included because the date() function is used to convert values to dates (similar to a C/C++ cast)

Code Flags:
CONSTANT
Parameters
dtthe date to return
Returns
the date passed
date Qore::date ( string  dtstr)

Converts the argument to a date and returns the date.

Code Flags:
CONSTANT
Parameters
dtstrstring a string to bo converted literally to an absolute date/time value; if no time zone information is present, the local time zone is assumed
Returns
the absolute date/time value corresponding to the string argument passed
Example:
my date $d = date("2001-01-01T15:35:23"); # returns 2001-01-01 15:35:23 Mon +01:00 (CET)
my date $d = date("20010101 15:35:23Z"); # returns 2001-01-01 15:35:23 Mon Z (UTC)
my date $d = date("20010101 153523Z"); # returns 2001-01-01 15:35:23 Mon Z (UTC)
my date $d = date("20010101 153523-02"); # returns 2001-01-01 15:35:23 Mon -02:00 (-02:00)
my date $d = date("20010101 153523-02:00:00"); # returns 2001-01-01 15:35:23 Mon -02:00 (-02:00)
my date $d = date("2001-01-01-153523-020000"); # returns 2001-01-01 15:35:23 Mon -02:00 (-02:00)
my date $d = date("20010101-153523"); # returns 2001-01-01 15:35:23 Mon +01:00 (CET)
See also
date(string, string)
date Qore::date ( float  f)

The argument is assumed to be the number of seconds and fractions of a second since 1970-01-01 in the local time zone; this value is used to produce the date value that is returned.

Code Flags:
CONSTANT
Parameters
fthe number of seconds and fractions of a second since 1970-01-01 in the local time zone
Returns
a date corresponding to the number of seconds and fractions of a second since 1970-01-01 in the local time zone passed as the sole argument
Example:
my date $d = date($f);
date Qore::date ( softint  i)

The argument is assumed to be the number of seconds since 1970-01-01 in the local time zone; this value is used to produce the date value that is returned.

Code Flags:
CONSTANT
Parameters
ithe number of seconds since 1970-01-01 in the local time zone
Returns
a date corresponding to the number of seconds since 1970-01-01 in the local time zone passed as the sole argument
Example:
my date $d = date($i);
date Qore::date ( )

This function just returns 1970-01-01Z.

Code Flags:
CONSTANT

This function is included because the date() function is used to convert values to dates (similar to a C/C++ cast)

Returns
1970-01-01Z
date Qore::date ( null  null)

This function just returns 1970-01-01Z.

Code Flags:
CONSTANT

This function is included because the date() function is used to convert values to dates (similar to a C/C++ cast)

Returns
1970-01-01Z
date Qore::date ( string  dtstr,
string  mask 
)

Returns the date/time value corresponding to parsing a string argument according to a format mask.

Code Flags:
RET_VALUE_ONLY
Parameters
dtstra string giving a date
maskthe mask for the date value; see Date Mask Format for information on the format of the format mask
Returns
the date/time value corresponding to parsing the dtstr string argument according to mask serving as a format mask
Example:
my date $dt = date("20100401 234520 230394", "YYYYMMDD HHmmSS ssssss"); # returns 2010-04-01T23:45:20.230394
Exceptions
DATE-CONVERT-ERRORinvalid mask specification
See also
Qore::TimeZone::date(string, string) for a method that allows the date to be parsed in a particular time zone
hash Qore::date_info ( date  dt)

Returns a hash of broken-down date/time information for the given date argument (can be either a relative or absolute date)

Code Flags:
CONSTANT
Parameters
dtthe date to return information for
Returns
a hash of broken-down date/time information for the given date argument
Example:
my hash $h = date_info($date);
Note
equivalent to <date>::info()
hash Qore::date_info ( )

Returns a hash of broken-down date/time information for the current date and time.

Returns
a hash of broken-down date/time information for the current date and time
Code Flags:
CONSTANT
Example:
my hash $h = date_info();
date Qore::date_ms ( softint  ms)

Converts an integer argument representing the offset in milliseconds from January 1, 1970 in the local time zone to a date in the local time zone.

Code Flags:
CONSTANT
Parameters
msan integer argument representing the offset in milliseconds from January 1, 1970 in the local time zone
Returns
a date in the local time zone corresponding to the argument passed which is an offset in milliseconds from January 1, 1970 in the local time zone
Example:
my date $date = date_ms(1); # returns 1970-01-01T00:00:00.001 in the local time zone
See also
date_us(softint)
nothing Qore::date_ms ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
date Qore::date_us ( softint  us)

Converts an integer argument representing the offset in microseconds from January 1, 1970 in the local time zone to a date in the local time zone.

Code Flags:
CONSTANT
Parameters
usan integer argument representing the offset in microseconds from January 1, 1970 in the local time zone
Returns
a date in the local time zone corresponding to the argument passed which is an offset in microseconds from January 1, 1970 in the local time zone
Example:
my date $date = date_us(1); # returns 1970-01-01T00:00:00.000001 in the local time zone
See also
date_ms(softint)
date Qore::days ( softint  days)

Returns a relative date/time value in days based on the integer argument passed to be used in date arithmetic.

Code Flags:
CONSTANT
Parameters
daysthe number of days to return
Returns
a relative date/time value in days based on the integer argument passed to be used in date arithmetic
Example:
my date $rd = days(100);
See also
nothing Qore::days ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
string Qore::format_date ( string  format,
date  dt 
)

Returns a formatted string for a date argument passed.

Code Flags:
CONSTANT
Parameters
formata string giving the format for the date; see Date Formatting Codes for more information about this string
dtthe date to use for the string output
Returns
a formatted string for a date argument passed
Example:
my string $str = format_date("Day, Mon D, YYYY-MM-DD HH:mm:SS", 2004-02-01T12:30:00);
# returns "Sunday, Feb 1, 2004-02-01 12:30:00"
Bug:
there is no locale support; day and month names and abbreviations are only returned in English
nothing Qore::format_date ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_days ( date  dt)

Returns an integer corresponding to the literal day value in the date (does not calculate a duration)

Code Flags:
CONSTANT
Parameters
dtthe date value; can be either a relative or absolute date
Returns
an integer corresponding to the day value in the date
Example:
my int $n = get_days($dt);
Note
equivalent to pseudo-method <date>::days()
nothing Qore::get_days ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_duration_microseconds ( date  dt)

Returns an integer value representing the the number of microseconds of duration in the value of the date passed (can be either a relative or absolute date)

Code Flags:
CONSTANT
Parameters
dta relative or absolute date argument
Returns
an integer value representing the the number of microseconds of duration in the value of the date passed; if the argument is a relative date, the value is normalized to microseconds and the integer microseconds value is returned, if the argument is an absolute date, the duration in microseconds is calculated from the present time; so if the present time is sent as an argument, 0 is returned, if a future date is used, the number of microseconds from the present time to the future date is returned, if an absolute date in the past is passed as an argument, also 0 is returned (the function does not calculate microsecond differences for absolute dates in the past (for this use Date/Time Arithmetic instead); this function can only return a negative value if passed a relative date/time value
Example:
my int $us = get_duration_microseconds(PT2M15S3u); # returns 135000003
Note
See also
int Qore::get_duration_milliseconds ( date  dt)

Returns an integer value representing the the number of milliseconds of duration in the value of the date passed (can be either a relative or absolute date)

The duration in milliseconds is calculated and any fractional milliseconds are truncated (no rounding is performed)

Code Flags:
CONSTANT
Parameters
dta relative or absolute date argument
Returns
an integer value representing the the number of milliseconds of duration in the value of the date passed; if the argument is a relative date, the value is normalized to milliseconds and the integer milliseconds value is returned, if the argument is an absolute date, the duration in milliseconds is calculated from the present time; so if the present time is sent as an argument, 0 is returned, if a future date is used, the number of milliseconds from the present time to the future date is returned, if an absolute date in the past is passed as an argument, also 0 is returned (the function does not calculate millisecond differences for absolute dates in the past (for this use Date/Time Arithmetic instead); this function can only return a negative value if passed a relative date/time value
Example:
my int $ms = get_duration_milliseconds(PT2M15S3u); # returns 135000
Note
See also
int Qore::get_duration_seconds ( date  dt)

Returns an integer value representing the the number of seconds of duration in the value of the date passed (can be either a relative or absolute date)

The duration in seconds is calculated and any fractional seconds are truncated (no rounding is performed)

Code Flags:
CONSTANT
Parameters
dta relative or absolute date argument
Returns
an integer value representing the the number of seconds of duration in the value of the date passed; if the argument is a relative date, the value is normalized to seconds and the integer seconds value is returned, if the argument is an absolute date, the duration in seconds is calculated from the present time; so if the present time is sent as an argument, 0 is returned, if a future date is used, the number of seconds from the present time to the future date is returned, if an absolute date in the past is passed as an argument, also 0 is returned (the function does not calculate second differences for absolute dates in the past (for this use Date/Time Arithmetic instead); this function can only return a negative value if passed a relative date/time value
Example:
my int $us = get_duration_seconds(PT2M15S3u); # returns 135
Note
See also
int Qore::get_epoch_seconds ( date  dt)

Returns the number of seconds of the date and time in local time passed since Jan 1, 1970, 00:00:00 Z (UTC); negative values are returned for dates before the epoch.

Code Flags:
CONSTANT
Parameters
dtThe date to process
Returns
the number of seconds of the date and time in local time passed since Jan 1, 1970, 00:00:00 Z (UTC); negative values are returned for dates before the epoch
Example:
my int $i = get_epoch_seconds(2012-01-19T08:02:15+01:00);
See also
timegm(date)
Note
This function is equivalent to mktime(date)
nothing Qore::get_epoch_seconds ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_hours ( date  dt)

Returns an integer corresponding to the literal hour value in the date (does not calculate a duration)

Code Flags:
CONSTANT
Parameters
dtthe date value; can be either a relative or absolute date
Returns
an integer corresponding to the hour value in the date
Example:
my int $n = get_hours($dt);
Note
equivalent to pseudo-method <date>::hours()
nothing Qore::get_hours ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_microseconds ( date  dt)

Returns an integer corresponding to the literal microsecond value in the date (does not calculate a duration)

Code Flags:
CONSTANT
Parameters
dtthe date value; can be either a relative or absolute date
Returns
an integer corresponding to the literal microsecond value in the date (does not calculate a duration)
Example:
my int $n = get_microseconds($dt);
Note
date Qore::get_midnight ( date  dt)

Returns midnight on the date passed (strips the time component on the new value)

Code Flags:
CONSTANT
Parameters
dtthe date to process
Returns
midnight on the date passed (strips the time component on the new value)
Example:
my date $midnight = get_midnight($dt);
Note
equivalent to pseudo-method <date>::midnight()
nothing Qore::get_midnight ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_milliseconds ( date  dt)

Returns an integer corresponding to the literal millisecond value in the date (does not calculate a duration)

Code Flags:
CONSTANT
Parameters
dtthe date value; can be either a relative or absolute date
Returns
an integer corresponding to the literal millisecond value in the date (does not calculate a duration)
Example:
my int $n = get_milliseconds($dt);
Note
nothing Qore::get_milliseconds ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_minutes ( date  dt)

Returns an integer corresponding to the literal minute value in the date (does not calculate a duration)

Code Flags:
CONSTANT
Parameters
dtthe date value; can be either a relative or absolute date
Returns
an integer corresponding to the minute value in the date
Example:
my int $n = get_minutes($dt);
Note
equivalent to pseudo-method <date>::minutes()
nothing Qore::get_minutes ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_months ( date  dt)

Returns an integer corresponding to the literal month value in the date (does not calculate a duration)

Code Flags:
CONSTANT
Parameters
dtthe date value; can be either a relative or absolute date
Returns
an integer corresponding to the month value in the date
Example:
my int $n = get_months($dt);
Note
equivalent to pseudo-method <date>::months()
nothing Qore::get_months ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_seconds ( date  dt)

Returns an integer corresponding to the literal second value in the date (does not calculate a duration)

Code Flags:
CONSTANT
Parameters
dtthe date value; can be either a relative or absolute date
Returns
an integer corresponding to the literal second value in the date (does not calculate a duration)
Example:
my int $n = get_seconds($dt);
Note
nothing Qore::get_seconds ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::get_years ( date  dt)

Returns an integer corresponding to the literal year value in the date (does not calculate a duration)

Code Flags:
CONSTANT
Parameters
dtthe date value; can be either a relative or absolute date
Returns
an integer corresponding to the year value in the date
Example:
my int $n = get_years($dt);
Note
equivalent to pseudo-method <date>::years()
nothing Qore::get_years ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
date Qore::getDateFromISOWeek ( softint  year,
softint  week,
softint  day = 1 
)

Retuns an absolute date value for the ISO-8601 calendar week information passed (year, week number, optional: weekday, where 1=Monday, 7=Sunday) in the current time zone.

Throws an exception if the arguments are invalid

Code Flags:
RET_VALUE_ONLY
Parameters
yearthe ISO-8601 year (which for some special days does not always correspond to the actual calendar year)
weekthe ISO-8601 week number; if this argument is invalid, an ISO-8601-INVALID-WEEK exception is thrown
daythe day of the week, where 1=Monday and 7=Sunday; if this argument is invalid, an ISO-8601-INVALID-DAY exception is thrown
Returns
an absolute date value for the ISO-8601 calendar week information passed (year, week number, optional: weekday, where 1=Monday, 7=Sunday) in the current time zone
Example:
my date $d = getDateFromISOWeek(2007, 3); # returns 2007-01-15
Exceptions
ISO-8601-INVALID-WEEKThe week number is not valid for the given year
ISO-8601-INVALID-DAYThe day number is not between 1 (Monday) and 7 (Sunday) inclusive
int Qore::getDayNumber ( date  dt)

Returns an integer representing the ordinal day number in the year (corresponding to the ISO-8601 day number) for the absolute date value passed.

Code Flags:
CONSTANT
Parameters
dtan absolute date value to get the ordinal day number
Returns
an integer representing the ordinal day number in the year (corresponding to the ISO-8601 day number) for the absolute date value passed; if a relative date value is passed, then this function will return 0
Example:
my int $dn = getDayNumber($dt);
nothing Qore::getDayNumber ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::getDayOfWeek ( date  dt)

Returns an integer representing the day of the week for the absolute date value passed (0=Sunday, 6=Saturday)

Code Flags:
CONSTANT
Parameters
dtan absolute date value to get the number for the day of the week
Returns
an integer representing the day of the week for the absolute date value passed (0=Sunday, 6=Saturday); if a relative date value is passed, then this function will return 0
Example:
my int $dn = getDayOfWeek($dt);
See also
getISODayOfWeek(date)
nothing Qore::getDayOfWeek ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::getISODayOfWeek ( date  dt)

Returns an integer representing the ISO-8601 day of the week for the absolute date value passed (1=Monday, 7=Sunday)

Code Flags:
CONSTANT
Parameters
dtan absolute date value to get the number for the day of the week
Returns
an integer representing the day of the week for the absolute date value passed (1=Monday, 7=Sunday); if a relative date value is passed, then this function will return 7
Example:
my int $dn = getISODayOfWeek($dt);
See also
getDayOfWeek(date)
nothing Qore::getISODayOfWeek ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
hash Qore::getISOWeekHash ( date  dt)

Returns a hash representing the ISO-8601 calendar week information for the absolute date passed (hash keys: "year", "week", "day")

Note
that the ISO-8601 year does not always correspond with the calendar year at the end and the beginning of every year (for example 2006-01-01 in ISO-8601 calendar week format is: year=2005, week=52, day=7)
Code Flags:
CONSTANT
Parameters
dtthe date to get information for
Returns
a hash representing the ISO-8601 calendar week information for the absolute date passed (hash keys: "year", "week", "day"); if a relative date value is passed, then this function will return year=1970, week=1, day=1
Example:
my hash $h = getISOWeekHash(2007-05-15); # returns year=2007, week=20, day=2
See also
getISOWeekString(date)
nothing Qore::getISOWeekHash ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
string Qore::getISOWeekString ( date  dt)

Returns a string representing the ISO-8601 calendar week information for the absolute date passed (ex: 2006-01-01 = "2005-W52-7")

Code Flags:
CONSTANT
Parameters
dtthe date to get information for
Returns
a string representing the ISO-8601 calendar week information for the absolute date passed (ex: 2006-01-01 = "2005-W52-7"); if a relative date value is passed, then this function will return "1970-W01-1"
Example:
my string $str = getISOWeekString(2007-05-15); # returns "2007-W20-2"
See also
getISOWeekHash(date)
nothing Qore::getISOWeekString ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
date Qore::gmtime ( )

Returns the current UTC (GMT) time with a resolution of a second.

Returns
the current UTC (GMT) time with a resolution of a second
Code Flags:
CONSTANT
Example:
my date $utc = gmtime();
See also
date Qore::gmtime ( softint  secs,
softint  us = 0 
)

Returns a date/time value in UTC (GMT) from arguments giving the number of seconds and microseconds since Jan 1, 1970, 00:00:00 Z (UTC)

Code Flags:
CONSTANT
Parameters
secsthe number of seconds and microseconds since Jan 1, 1970, 00:00:00 Z (UTC)
usa microsecond offset for the time returned
Returns
a date/time value in UTC (GMT) from arguments giving the number of seconds and microseconds since Jan 1, 1970, 00:00:00 Z (UTC)
Example:
my date $dt = gmtime(10);
See also
localtime(softint, softint)
date Qore::gmtime ( date  dt)

Returns the date and time in UTC (GMT) corresponding to the date argument passed.

Code Flags:
CONSTANT
Parameters
dta date to process; if the date passed is already in UTC, then the same value is returned
Returns
the date and time in UTC (GMT) corresponding to the date argument passed
Example:
my date $dt = gmtime(2012-01-19T15:00:00-07:00);
See also
localtime(date)
date Qore::hours ( softint  hours)

Returns a relative date/time value in hours based on the integer argument passed to be used in date arithmetic.

Code Flags:
CONSTANT
Parameters
hoursthe number of hours to return
Returns
a relative date/time value in hours based on the integer argument passed to be used in date arithmetic
Example:
my date $rd = hours(100);
See also
nothing Qore::hours ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
bool Qore::is_date_absolute ( date  dt)

Returns True if the argument is an absolute date/time value, False if not.

Code Flags:
CONSTANT
Parameters
dtthe date to check
Returns
True if the argument is an absolute date/time value, False if not
Example:
my bool $b = is_date_absolute($dt)
See also
is_date_relative()
bool Qore::is_date_absolute ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
NOOP
bool Qore::is_date_relative ( date  dt)

Returns True if the argument is an relative date/time value, False if not.

Code Flags:
CONSTANT
Parameters
dtthe date to check
Returns
True if the argument is an relative date/time value, False if not
Example:
my bool $b = is_date_relative($dt)
See also
is_date_absolute()
bool Qore::is_date_relative ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
NOOP
date Qore::localtime ( )

Returns the current date and time with a resolution to the second.

Returns
the current date and time with a resolution to the second
Code Flags:
CONSTANT
Example:
my date $d = localtime();
See also
gmtime()
Note
this variant of localtime() is equivalent to now()
date Qore::localtime ( softint  secs,
softint  us = 0 
)

Returns the date and time in the local time zone corresponding to the integer arguments passed, which are interpreted as the number of seconds and microseconds since Jan 1, 1970, 00:00:00 Z (UTC)

Code Flags:
CONSTANT
Parameters
secsthe number of seconds and microseconds since Jan 1, 1970, 00:00:00 Z (UTC)
usa microsecond offset for the time returned
Returns
the date and time in the local time zone corresponding to the arguments passed
Example:
my date $dt = localtime(10);
See also
gmtime(softint, softint)
date Qore::localtime ( date  dt)

Returns the date and time in the local time zone corresponding to the date argument passed.

Code Flags:
CONSTANT
Parameters
dta date to process; if the date passed is in the local time zone, then the same value is returned
Returns
the date and time in the local time zone corresponding to the date argument passed
Example:
my date $dt = localtime(2012-01-19T15:00:00-07:00);
See also
gmtime(date)
date Qore::microseconds ( softint  us)

Returns a relative date/time value in microseconds based on the integer argument passed to be used in date arithmetic.

Code Flags:
CONSTANT
Parameters
usthe number of microseconds to return
Returns
a relative date/time value in microseconds based on the integer argument passed to be used in date arithmetic
Example:
my date $rd = microseconds(100);
See also
date Qore::milliseconds ( softint  ms)

Returns a relative date/time value in milliseconds based on the integer argument passed to be used in date arithmetic.

Code Flags:
CONSTANT
Parameters
msthe number of milliseconds to return
Returns
a relative date/time value in milliseconds based on the integer argument passed to be used in date arithmetic
Example:
my date $rd = milliseconds(100);
See also
nothing Qore::milliseconds ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
date Qore::minutes ( softint  minutes)

Returns a relative date/time value in minutes based on the integer argument passed to be used in date arithmetic.

Code Flags:
CONSTANT
Parameters
minutesthe number of minutes to return
Returns
a relative date/time value in minutes based on the integer argument passed to be used in date arithmetic
Example:
my date $rd = minutes(100);
See also
nothing Qore::minutes ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::mktime ( date  dt)

Returns the number of seconds of the date and time in local time passed since Jan 1, 1970, 00:00:00 Z (UTC); negative values are returned for dates before the epoch.

Code Flags:
CONSTANT
Parameters
dtThe date to process
Returns
the number of seconds of the date and time in local time passed since Jan 1, 1970, 00:00:00 Z (UTC); negative values are returned for dates before the epoch
Example:
my int $i = mktime(2012-01-19T08:02:15+01:00);
See also
timegm(date)
Note
This function is equivalent to get_epoch_seconds(date)
nothing Qore::mktime ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
date Qore::months ( softint  months)

Returns a relative date/time value in months based on the integer argument passed to be used in date arithmetic.

Code Flags:
CONSTANT
Parameters
monthsthe number of months to return
Returns
a relative date/time value in months based on the integer argument passed to be used in date arithmetic
Example:
my date $rd = months(100);
See also
nothing Qore::months ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
date Qore::now ( )

Returns the current date and time with a resolution to the second.

Returns
the current date and time with a resolution to the second
Code Flags:
CONSTANT
Example:
my date $d = now();
See also
Note
this function is equivalent to localtime()
date Qore::now_ms ( )

Returns the current date and time with a resolution to the millisecond.

Returns
the current date and time with a resolution to the millisecond
Code Flags:
CONSTANT
Example:
my date $d = now_ms();
See also
  • now() For a similar function returning the current date and time in the local time zone with coarser granularity, when resolution only to the second is needed
  • now_us() for a similar function returning the current date and time with a resolution to the microsecond
  • now_utc();
Note
There is no performance penalty for using now_ms() and now_us() versus now(); now() and now_ms() are kept for backwards compatibility
date Qore::now_us ( )

Returns the current date and time with a resolution to the microsecond.

Returns
the current date and time with a resolution to the microsecond
Code Flags:
CONSTANT
Example:
my date $d = now_us();
See also
  • now() For a similar function returning the current date and time in the local time zone with coarser granularity, when resolution only to the second is needed
  • now_ms() for a similar function returning the current date and time in the local time zone with coarser granularity, when resolution only to the millisecond is needed
  • now_utc();
Note
There is no performance penalty for using now_ms() and now_us() versus now(); now() and now_ms() are kept for backwards compatibility
date Qore::now_utc ( )

Returns the current UTC date and time with a resolution to the microsecond.

Returns
the current UTC date and time with a resolution to the microsecond
Code Flags:
CONSTANT
Example:
my date $d = now_utc();
See also
now_us() for a similar function that returns the current date and time in the local time zone
date Qore::seconds ( softint  seconds)

Returns a relative date/time value in seconds based on the integer argument passed to be used in date arithmetic.

Code Flags:
CONSTANT
Parameters
secondsthe number of seconds to return
Returns
a relative date/time value in seconds based on the integer argument passed to be used in date arithmetic
Example:
my date $rd = seconds(100);
See also
nothing Qore::seconds ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
int Qore::timegm ( date  dt)

Returns the number of seconds since January 1, 1970 00:00:00 in the local time zone for the given date.

Code Flags:
CONSTANT
Parameters
dtThe date to process
Returns
the number of seconds since January 1, 1970 00:00:00 in the local time zone for the given date
Example:
int secs = timegm($dt);
See also
get_epoch_seconds(date)
nothing Qore::timegm ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP
date Qore::years ( softint  years)

Returns a relative date/time value in years based on the integer argument passed to be used in date arithmetic.

Code Flags:
CONSTANT
Parameters
yearsthe number of years to return
Returns
a relative date/time value in years based on the integer argument passed to be used in date arithmetic
Example:
my date $y = years(100);
See also
nothing Qore::years ( )

This function variant does nothing at all; it is only included for backwards-compatibility with qore prior to version 0.8.0 for functions that would ignore type errors in arguments.

Code Flags:
RUNTIME_NOOP