Qore Programming Language Reference Manual  1.8.0
<date> Class Reference

Methods in this pseudo-class can be executed on date/time value types. More...

Inheritance diagram for Qore::<date>:

Public Member Methods

bool absolute ()
 Returns True if the date is an absolute date/time value. More...
 
*string currentZoneName ()
 Returns the name of the current time zone for the current absolute date/time value (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) or a UTC offset (like "+01") or "UTC" or NOTHING for relative date/time values. More...
 
int dayNumber ()
 Returns an integer representing the ordinal day number in the year (corresponding to the ISO-8601 day number) for the absolute date value. More...
 
int dayOfWeek ()
 Returns an integer representing the day of the week for the absolute date value (0=Sunday, 6=Saturday) More...
 
int days ()
 Returns an integer corresponding to the literal day value in the date (does not calculate a duration) More...
 
int durationMicroseconds ()
 Returns an integer value representing the the number of microseconds of time duration in the date value (can be either a relative or absolute date) More...
 
int durationMilliseconds ()
 Returns an integer value representing the the number of milliseconds of time duration in the date value (can be either a relative or absolute date) More...
 
int durationSeconds ()
 Returns an integer value representing the the number of seconds of time duration in the date value (can be either a relative or absolute date) More...
 
float durationSecondsFloat ()
 Returns a floating-point 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...
 
string format (string format)
 Returns a formatted string for the date value. More...
 
int getEpochSeconds ()
 Returns the number of seconds since the start of the epoch (1970-01-01Z) for the current date for absolute date/time values; returns 0 for relative date/time values. More...
 
int getEpochSecondsLocalTime ()
 Returns the number of seconds since the start of the epoch (1970-01-01) for the current date in the local time zone for absolute date/time values; returns 0 for relative date/time values. More...
 
int getUtcOffset ()
 Returns the time zone offset for the current time in seconds east of UTC or -1 for relative date/time values. More...
 
int hours ()
 Returns an integer corresponding to the literal hour value in the date (does not calculate a duration) More...
 
hash< DateTimeInfoinfo ()
 Returns a DateTimeInfo hash for the date (can be either a relative or absolute date) More...
 
bool intp ()
 Returns True because date values can be converted to integers. More...
 
bool isDst ()
 Returns True if the current date/time value is currently in daylight savings time. More...
 
int isoDayOfWeek ()
 Returns an integer representing the ISO-8601 day of the week for the absolute date value (1=Monday, 7=Sunday) More...
 
hash< IsoWeekInfoisoWeekHash ()
 Returns an IsoWeekInfo hash representing the ISO-8601 calendar week information for the absolute date (hash keys: "year", "week", "day") More...
 
string isoWeekString ()
 Returns a string representing the ISO-8601 calendar week information for the absolute date (ex: 2006-01-01 = "2005-W52-7") More...
 
int microseconds ()
 Returns an integer corresponding to the literal microsecond value in the date (does not calculate a duration) More...
 
date midnight ()
 Returns midnight on the given date (strips the time component on the new value) More...
 
int milliseconds ()
 Returns an integer corresponding to the literal millisecond value in the date (does not calculate a duration) More...
 
int minutes ()
 Returns an integer corresponding to the literal minute value in the date (does not calculate a duration) More...
 
int months ()
 Returns an integer corresponding to the literal month value in the date (does not calculate a duration) More...
 
bool relative ()
 Returns True if the date is a relative date/time value. More...
 
int seconds ()
 Returns an integer corresponding to the literal second value in the date (does not calculate a duration) More...
 
bool strp ()
 Returns True because boolean values can be converted to strings. More...
 
int typeCode ()
 Returns Qore::NT_DATE. More...
 
bool val ()
 Returns False if the date value is all zeros, True if not. More...
 
int years ()
 Returns an integer corresponding to the literal year value in the date (does not calculate a duration) More...
 
*TimeZone zone ()
 Returns a Qore::TimeZone object for the time zone of the date/time value; returns NOTHING for relative date/time values. More...
 
- Public Member Methods inherited from <value>
bool callp ()
 Returns False; this method is reimplemented in other types and will return True if the given expression is a callable value (ie closures or call references) More...
 
bool complexType ()
 returns True if the value has a complex type, False if not More...
 
bool empty ()
 Returns True; this method will be reimplemented in container types where it may return False. More...
 
string fullType (*bool with_namespaces)
 returns the full type name which differs from the simple type name in case of complex types and objects More...
 
bool intp ()
 Returns False; this method is reimplemented in other types and will return True if the given expression can be converted to an integer. More...
 
AbstractIterator iterator ()
 Returns an iterator object for the value; the default iterator object returned is SingleValueIterator. More...
 
int lsize ()
 Returns 1; the return value of this method should give the list size of the value, which is normally 1 for non-lists (except for NOTHING where the size will be 0) and the number of the elements in the list for lists; this method will be reimplemented in other types where it may return other values. More...
 
int size ()
 Returns zero; this method will be reimplemented in container types where it may return a non-zero value. More...
 
bool sizep ()
 Returns True if the type can return a non-zero size (True for containers including binary objects and strings, False for everything else) More...
 
bool strp ()
 Returns False; this method is reimplemented in other types and will return True if the given expression can be converted to a string. More...
 
bool toBool ()
 Returns the boolean representation of the value; the default is False. More...
 
float toFloat ()
 Returns the floating-point representation of the value; the default is 0.0. More...
 
int toInt ()
 Returns the integer representation of the value; the default is 0. More...
 
number toNumber ()
 Returns the arbitrary-precision numeric representation of the value; the default is 0. More...
 
string toString ()
 Returns the string representation of the value; the default is an empty string. More...
 
string type ()
 Returns the string type for the value. More...
 
int typeCode ()
 Returns the type code for the value. More...
 
bool val ()
 Returns False; this method is reimplemented in other types and will return True if the given expression has a non-empty value. More...
 

Detailed Description

Methods in this pseudo-class can be executed on date/time value types.

Member Function Documentation

◆ absolute()

bool <date>::absolute ( )

Returns True if the date is an absolute date/time value.

Returns
True if the date is an absolute date/time value
Example:
bool b = d.absolute();

◆ currentZoneName()

*string <date>::currentZoneName ( )

Returns the name of the current time zone for the current absolute date/time value (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) or a UTC offset (like "+01") or "UTC" or NOTHING for relative date/time values.

Returns
the name of the current time zone for the current absolute date/time value (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) or a UTC offset (like "+01") or "UTC" or NOTHING for relative date/time values
Code Flags:
CONSTANT
Example:
*string zn = d.currentZoneName();

◆ dayNumber()

int <date>::dayNumber ( )

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

Returns
an integer representing the ordinal day number in the year (corresponding to the ISO-8601 day number) for the absolute date value; if a relative date value is used, then this method will return 0
Code Flags:
CONSTANT
Example:
int dn = dt.dayNumber();
Note
equivalent to Qore::get_day_number()
Since
Qore 0.8.12

◆ dayOfWeek()

int <date>::dayOfWeek ( )

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

Returns
an integer representing the day of the week for the absolute date value (0=Sunday, 6=Saturday); if a relative date value is used, then this method will return 0
Code Flags:
CONSTANT
Example:
int dn = dt.dayOfWeek();
Note
equivalent to Qore::get_day_of_week()
See also
<date>::isoDayOfWeek()
Since
Qore 0.8.12

◆ days()

int <date>::days ( )

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

The date value can be either a relative or absolute date.

Returns
an integer corresponding to the literal day value in the date (does not calculate a duration)
Code Flags:
CONSTANT
Example:
int n = d.days();
Note
equivalent to get_days(date)

◆ durationMicroseconds()

int <date>::durationMicroseconds ( )

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

Returns
an integer value representing the the number of microseconds in the date value; if the value is a relative date, the value is normalized to microseconds and the integer microseconds value is returned, if the value 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 used, also 0 is returned (the pseudo-method does not calculate microsecond differences for absolute dates in the past (for this use Date/Time Arithmetic instead); this method can only return a negative value if passed a relative date/time value
Code Flags:
CONSTANT
Example:
int us = PT2M15S3u.durationMicroseconds(); # returns 135000003
Note
See also
Since
Qore 0.8.7

◆ durationMilliseconds()

int <date>::durationMilliseconds ( )

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

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

Returns
an integer value representing the the number of milliseconds in the date value; if the value is a relative date, the value is normalized to milliseconds and the integer milliseconds value is returned, if the value 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 used, also 0 is returned (the pseudo-method does not calculate millisecond differences for absolute dates in the past (for this use Date/Time Arithmetic instead); this method can only return a negative value if passed a relative date/time value
Code Flags:
CONSTANT
Example:
int us = PT2M15S3u.durationMilliseconds(); # returns 135000
Note
See also
Since
Qore 0.8.7

◆ durationSeconds()

int <date>::durationSeconds ( )

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

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

Returns
an integer value representing the the number of seconds in the date value; if the value is a relative date, the value is normalized to seconds and the integer seconds value is returned, if the value 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 used, also 0 is returned (the pseudo-method does not calculate second differences for absolute dates in the past (for this use Date/Time Arithmetic instead); this method can only return a negative value if passed a relative date/time value
Code Flags:
CONSTANT
Example:
int us = PT2M15S3u.durationSeconds(); # returns 135
Note
See also
Since
Qore 0.8.7

◆ durationSecondsFloat()

float <date>::durationSecondsFloat ( )

Returns a floating-point 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 returned as digits to the right of the decimal point.

Returns
a floating-point vaaue 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 floating-point seconds value is returned with microseconds providing the digits to the right of the decimal place, 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
Code Flags:
CONSTANT
Example:
float dt = PT2M15S3u.durationSecondsFloat(); # returns 135.000003
Note
See also
Since
Qore 0.8.12

◆ format()

string <date>::format ( string  format)

Returns a formatted string for the date value.

Code Flags:
CONSTANT
Parameters
formata string giving the format for the date; see Date Formatting Codes for more information about this string
Returns
a formatted string for a date argument passed
Example:
string str = d.format("Day, Mon D, YYYY-MM-DD HH:mm:SS");
Bug:
there is no locale support; day and month names and abbreviations are only returned in English
Note
equivalent to format_date(string, date)

◆ getEpochSeconds()

int <date>::getEpochSeconds ( )

Returns the number of seconds since the start of the epoch (1970-01-01Z) for the current date for absolute date/time values; returns 0 for relative date/time values.

Code Flags:
CONSTANT
Example:
int secs = d.getEpochSeconds();
Returns
the number of seconds since the start of the epoch (1970-01-01Z) for the current date for absolute date/time values; returns 0 for relative date/time values
Since
Qore 0.8.8

◆ getEpochSecondsLocalTime()

int <date>::getEpochSecondsLocalTime ( )

Returns the number of seconds since the start of the epoch (1970-01-01) for the current date in the local time zone for absolute date/time values; returns 0 for relative date/time values.

Code Flags:
CONSTANT
Example:
int secs = d.getEpochSecondsLocalTime();
Returns
the number of seconds since the start of the epoch (1970-01-01) for the current date in the local time zone for absolute date/time values; returns 0 for relative date/time values
Since
Qore 0.8.8

◆ getUtcOffset()

int <date>::getUtcOffset ( )

Returns the time zone offset for the current time in seconds east of UTC or -1 for relative date/time values.

Returns
the time zone offset for the current time in seconds east of UTC or -1 for relative date/time values
Code Flags:
CONSTANT
Example:
int utcoffset = d.getUtcOffset();

◆ hours()

int <date>::hours ( )

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

The date value can be either a relative or absolute date.

Returns
an integer corresponding to the literal hour value in the date (does not calculate a duration)
Code Flags:
CONSTANT
Example:
int n = d.hours();
Note
equivalent to get_hours(date)

◆ info()

hash<DateTimeInfo> <date>::info ( )

Returns a DateTimeInfo hash for the date (can be either a relative or absolute date)

Code Flags:
CONSTANT
Example:
hash<DateTimeInfo> h = d.info(date);
Returns
a DateTimeInfo hash for the given date argument
Note
equivalent to date_info(date)
Since
Qore 0.8.8

◆ intp()

bool <date>::intp ( )

Returns True because date values can be converted to integers.

Returns
True because date values can be converted to integers
Code Flags:
CONSTANT
Example:
if (n.intp())
printf("%y: can be converted to an integer: %d\n", n, int(n));
string printf(string fmt,...)
Outputs the string passed to standard output, using the first argument as a format string; does not e...
int int(string str, int base=10)
Converts the string to an integer value with respect to the base.

◆ isDst()

bool <date>::isDst ( )

Returns True if the current date/time value is currently in daylight savings time.

Returns
True if the current date/time value is currently in daylight savings time; always returns False for relative date/time values
Code Flags:
CONSTANT
Example:
bool b = d.isDst();

◆ isoDayOfWeek()

int <date>::isoDayOfWeek ( )

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

Returns
an integer representing the day of the week for the absolute date passed (1=Monday, 7=Sunday); if a relative date value is used, then this method will return 7
Code Flags:
CONSTANT
Example:
int dn = dt.isoDayOfWeek();
Note
equivalent to Qore::get_iso_day_of_week()
See also
<date>::dayOfWeek()
Since
Qore 0.8.12

◆ isoWeekHash()

hash<IsoWeekInfo> <date>::isoWeekHash ( )

Returns an IsoWeekInfo hash representing the ISO-8601 calendar week information for the absolute date (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)
Returns
an IsoWeekInfo hash representing the ISO-8601 calendar week information for the absolute date (hash keys: "year", "week", "day"); if a relative date value is used, then this method will return year=1970, week=1, day=1
Code Flags:
CONSTANT
Example:
hash<IsoWeekInfo> h = 2007-05-15.isoWeekHash(); # returns year=2007, week=20, day=2
Note
equivalent to Qore::get_iso_week_hash()
See also
<date>::isoWeekString()
Since
Qore 0.8.12

◆ isoWeekString()

string <date>::isoWeekString ( )

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

Returns
a string representing the ISO-8601 calendar week information for the absolute date (ex: 2006-01-01 = "2005-W52-7"); if a relative date value is used, then this method will return "1970-W01-1"
Code Flags:
CONSTANT
Example:
string str = 2007-05-15.isoWeekString(); # returns "2007-W20-2"
Note
equivalent to Qore::get_iso_week_string()
See also
<date>::isoWeekHash()
Since
Qore 0.8.12

◆ microseconds()

int <date>::microseconds ( )

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

The 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)
Code Flags:
CONSTANT
Example:
int n = d.microseconds();
Note

◆ midnight()

date <date>::midnight ( )

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

Returns
midnight on the given date (strips the time component on the new value)
Code Flags:
CONSTANT
Example:
date midnight = dt.midnight();
Note
equivalent to get_midnight()
Since
Qore 0.8.5

◆ milliseconds()

int <date>::milliseconds ( )

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

The 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)
Code Flags:
CONSTANT
Example:
int n = d.milliseconds();
Note

◆ minutes()

int <date>::minutes ( )

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

The date value can be either a relative or absolute date.

Returns
an integer corresponding to the literal minute value in the date (does not calculate a duration)
Code Flags:
CONSTANT
Example:
int n = d.minutes();
Note
equivalent to get_minutes(date)

◆ months()

int <date>::months ( )

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

The date value can be either a relative or absolute date.

Returns
an integer corresponding to the literal month value in the date (does not calculate a duration)
Code Flags:
CONSTANT
Example:
int n = d.months();
Note
equivalent to get_months(date)

◆ relative()

bool <date>::relative ( )

Returns True if the date is a relative date/time value.

Returns
True if the date is a relative date/time value
Example:
bool b = d.relative();

◆ seconds()

int <date>::seconds ( )

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

The 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)
Code Flags:
CONSTANT
Example:
int n = d.seconds();
Note

◆ strp()

bool <date>::strp ( )

Returns True because boolean values can be converted to strings.

Returns
True because boolean values can be converted to strings
Code Flags:
CONSTANT
Example:
if (n.strp())
printf("%y: can be converted to a string: '%s'\n", n, string(n));
string string(softstring str, *string enc)
Converts the argument to a string.

◆ typeCode()

int <date>::typeCode ( )

Returns Qore::NT_DATE.

Returns
Qore::NT_DATE
Example:
switch (d.typeCode()) {
case NT_DATE:
printf("%y: is a date\n", d);
break;
}

◆ val()

bool <date>::val ( )

Returns False if the date value is all zeros, True if not.

Returns
False if the date value is all zeros, True if not
Code Flags:
CONSTANT
Example:
bool b = d.val();
See also

◆ years()

int <date>::years ( )

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

Returns
an integer corresponding to the literal year value in the date (does not calculate a duration)
Code Flags:
CONSTANT
Example:
int n = d.years();
Note
equivalent to get_years(date)

◆ zone()

*TimeZone <date>::zone ( )

Returns a Qore::TimeZone object for the time zone of the date/time value; returns NOTHING for relative date/time values.

Returns
a Qore::TimeZone object for the time zone of the date/time value; returns NOTHING for relative date/time values
Code Flags:
CONSTANT
Example:
*TimeZone zone = d.zone();