Qore Programming Language  0.9.2
DateTime Class Reference

Holds absolute and relative date/time values in Qore with precision to the microsecond. More...

#include <DateTime.h>

Inheritance diagram for DateTime:

Public Member Methods

DLLEXPORT DateTime (bool r=false)
 constructor for an empty object More...
 
DLLEXPORT DateTime (int n_year, int n_month, int n_day, int n_hour=0, int n_minute=0, int n_second=0, short n_ms=0, bool n_relative=false)
 constructor for setting all parameters More...
 
DLLEXPORT DateTime (int64 seconds)
 constructor for setting an absolute date based on the number of seconds from January 1, 1970 More...
 
DLLEXPORT DateTime (int64 seconds, int ms)
 constructor for setting an absolute date based on the number of seconds from January 1, 1970 (plus milliseconds) More...
 
DLLEXPORT DateTime (const AbstractQoreZoneInfo *zone, const QoreValue v)
 constructor for creating an absolute date from a value representing a number of seconds More...
 
DLLEXPORT DateTime (const QoreValue v)
 constructor for creating a relative date from a value representing a number of seconds More...
 
DLLEXPORT DateTime (const char *date)
 constructor for setting the date from a string More...
 
DLLEXPORT DateTime (const char *date, ExceptionSink *xsink)
 constructor for setting the date from a string with a flexible format, throws a Qore-language exception if the date string is invalid More...
 
DLLEXPORT DateTime (const AbstractQoreZoneInfo *zone, const char *date)
 constructor for setting the date from a string with a flexible format More...
 
DLLEXPORT DateTime (const hashdecl tm *tms)
 constructor for setting an absolute date based on a "hashdecl tm" More...
 
DLLEXPORT DateTime (const DateTime &dt)
 copy constructor
 
DLLEXPORT ~DateTime ()
 destroys the object and frees all memory
 
DLLEXPORT void addSecondsTo (int64 secs, int us=0)
 adds the given number of seconds (and microseconds) to the date/time value More...
 
DLLEXPORT void format (QoreString &str, const char *fmt) const
 formats the date/time value to a QoreString More...
 
DLLEXPORT int getDay () const
 returns the day portion of the date-time value (in local time according to the time zone for absolute date/time values) More...
 
DLLEXPORT int getDayNumber () const
 returns the ordinal number of the day in the year for absolute dates, sometimes (mistakenly) referred to as the Julian date More...
 
DLLEXPORT int getDayOfWeek () const
 returns the day of week for the current date (0-6, Sun-Sat) More...
 
DLLEXPORT int64 getEpochMicrosecondsUTC () const
 gets the number of microseconds since January 1, 1970Z for the current date More...
 
DLLEXPORT int64 getEpochMillisecondsUTC () const
 gets the number of milliseconds since January 1, 1970Z for the current date More...
 
DLLEXPORT int64 getEpochSeconds () const
 gets the number of seconds since January 1, 1970 for the current date offset in local time More...
 
DLLEXPORT int64 getEpochSecondsUTC () const
 gets the number of seconds since January 1, 1970Z for the current date More...
 
DLLEXPORT int getHour () const
 returns the hour portion of the date-time value (in local time according to the time zone for absolute date/time values) More...
 
DLLEXPORT void getInfo (const AbstractQoreZoneInfo *n_zone, qore_tm &info) const
 returns the broken-down time in the given time zone (n_zone = 0 means UTC)
 
DLLEXPORT void getInfo (qore_tm &info) const
 returns the broken-down time in the current time zone
 
DLLEXPORT void getISOWeek (int &year, int &week, int &day) const
 returns the ISO-8601 week information More...
 
DLLEXPORT int getMicrosecond () const
 returns the microsecond portion of the date-time value More...
 
DLLEXPORT int getMillisecond () const
 returns the microsecond portion of the date-time value divided by 1000 More...
 
DLLEXPORT int getMinute () const
 returns the minute portion of the date-time value (in local time according to the time zone for absolute date/time values) More...
 
DLLEXPORT int getMonth () const
 returns the month portion of the date-time value (in local time according to the time zone for absolute date/time values) More...
 
DLLEXPORT int64 getRelativeMicroseconds () const
 returns the difference as the number of microseconds between the date/time value and the local time at the moment of the call, for absolute date/time values; for relative date/time values, the duration is converted to microseconds and returned as an integer More...
 
DLLEXPORT int64 getRelativeMilliseconds () const
 returns the difference as the number of milliseconds between the date/time value and the local time at the moment of the call, for absolute date/time values; for relative date/time values, the duration is converted to milliseconds and returned as an integer More...
 
DLLEXPORT int64 getRelativeSeconds () const
 returns the difference as the number of seconds between the date/time value and the local time at the moment of the call for absolute date/time values; for relative date/time values, the duration is converted to seconds and returned as an integer More...
 
DLLEXPORT double getRelativeSecondsDouble () const
 returns the difference as the number of seconds between the date/time value and the local time at the moment of the call for absolute date/time values; for relative date/time values, the duration is converted to seconds and returned as a floating-point value with fractional seconds as digits to the right of the decimal point More...
 
DLLEXPORT int getSecond () const
 returns the second portion of the date-time value (in local time according to the time zone for absolute date/time values) More...
 
DLLEXPORT void getTM (hashdecl tm *tms) const
 sets a "hashdecl tm" from the current date/time value for the time zone for the object; use DateTime::getInfo() instead
 
DLLEXPORT short getYear () const
 returns the year portion of the date-time value (in local time according to the time zone for absolute date/time values) More...
 
DLLEXPORT const AbstractQoreZoneInfo * getZone () const
 gets the time zone for the object; returns 0 for relative date/time values
 
DLLEXPORT bool hasValue () const
 returns true if the object has a value, false if not (zero value = 1970-01-01Z for absolute times, or all relative components = 0)
 
DLLEXPORT bool isAbsolute () const
 returns true if the value is an absolute date-time value More...
 
DLLEXPORT bool isRelative () const
 returns true if the value is a relative date-time value More...
 
DLLEXPORT void setDate (int64 seconds)
 sets the absolute date value based on the number of seconds from January 1, 1970 More...
 
DLLEXPORT void setDate (int64 seconds, int ms)
 sets the absolute date value based on the number of seconds from January 1, 1970 UTC (plus milliseconds) More...
 
DLLEXPORT void setDate (const AbstractQoreZoneInfo *zone, int64 seconds, int us)
 sets the absolute date value based on the number of seconds from January 1, 1970 UTC (plus microseconds) More...
 
DLLEXPORT void setDate (const AbstractQoreZoneInfo *n_zone, int n_year, int n_month, int n_day, int n_hour=0, int n_minute=0, int n_second=0, int n_us=0)
 sets the date to an absolute date/time as given
 
DLLEXPORT void setDate (const char *str)
 sets an absolute date value from a string with a flexible format More...
 
DLLEXPORT void setDate (const char *str, ExceptionSink *xsink)
 sets an absolute date value from a string with a flexible format More...
 
DLLEXPORT void setDate (const AbstractQoreZoneInfo *zone, const char *str)
 sets an absolute date value from a time zone pointer and a string with a flexible format More...
 
DLLEXPORT void setDate (const hashdecl tm *tms, short ms=0)
 sets the absolute date from a "hashdecl tm" pointer and millisecond value
 
DLLEXPORT void setDate (const DateTime &date)
 sets the date from a DateTime reference
 
DLLEXPORT void setLocalDate (const AbstractQoreZoneInfo *zone, int64 seconds, int us)
 sets the absolute date value based on the number of seconds from January 1, 1970 in the given time zone (plus microseconds) More...
 
DLLEXPORT void setNow ()
 sets the current date and time in the current time zone; current contents are overwritten More...
 
DLLEXPORT void setNow (const AbstractQoreZoneInfo *zone)
 sets the current date and time in the given time zone; current contents are overwritten More...
 
DLLEXPORT void setRelativeDate (const char *str)
 sets a relative date from a string in the format YYYYMMDDHHmmSS
 
DLLEXPORT void setRelativeDateSeconds (int64 s, int us=0)
 set the object to a relative date/time value as given in seconds and optionally microseconds
 
DLLEXPORT void setTime (int h, int m, int s, short ms=0)
 sets the time from hours, minutes, seconds, and milliseconds More...
 
DLLEXPORT void setZone (const AbstractQoreZoneInfo *n_zone)
 changes the time zone for the time without updating the epoch offset
 
DLLEXPORT DateTimeunaryMinus () const
 returns the negative time from the current time
 
DLLEXPORT void unaryMinusInPlace ()
 converts the current value to the negative of itself
 

Static Public Member Methods

static DLLEXPORT int compareDates (const DateTime *left, const DateTime *right)
 returns -1, 0, or 1 if the left date is less than, equal, or greater than the right date
 
static DLLEXPORT DateTimegetDateFromISOWeek (int year, int week, int day, ExceptionSink *xsink)
 returns a DateTime value from ISO-8601 week and day offsets More...
 
static DLLEXPORT int getLastDayOfMonth (int month, int year)
 returns the number of days in the month given according to a proleptic gregorian calendar
 
static DLLEXPORT bool isLeapYear (int year)
 returns true if the year passed is a leap year according to a proleptic gregorian calendar
 
static DLLEXPORT DateTimemakeAbsolute (const AbstractQoreZoneInfo *n_zone, int n_year, int n_month, int n_day, int n_hour=0, int n_minute=0, int n_second=0, int n_us=0)
 static "constructor" to create an absolute time, including microseconds
 
static DLLEXPORT DateTimemakeAbsolute (const AbstractQoreZoneInfo *zone, int64 seconds, int us=0)
 static "constructor" to create an absolute time as an offset from the epoch, including microseconds More...
 
static DLLEXPORT DateTimemakeAbsoluteLocal (const AbstractQoreZoneInfo *zone, int64 seconds, int us=0)
 static "constructor" to create an absolute time as an offset from the given time zone's epoch, including microseconds More...
 
static DLLEXPORT DateTimemakeRelative (int n_year, int n_month, int n_day, int n_hour=0, int n_minute=0, int n_second=0, int n_us=0)
 static "constructor" to create a relative time, including microseconds
 
static DLLEXPORT DateTimemakeRelativeFromSeconds (int64 n_second, int n_us=0)
 static "constructor" to create a relative time, including microseconds
 

Private Member Methods

DLLLOCAL DateTime (qore_date_private *n_priv)
 this constructor is not exported in the library
 
DLLLOCAL DateTimeoperator= (const DateTime &)
 this function is not implemented; it is here as a private function in order to prohibit it from being used
 

Private Attributes

class qore_date_private * priv
 private date data - most are ints so relative dates can hold a lot of data
 

Friends

class DateTimeNode
 

Detailed Description

Holds absolute and relative date/time values in Qore with precision to the microsecond.

Date arithmetic and date formatting is supported by this class. As of qore 0.8.0, the internal representation for absolute date/time values has changed. Now, absolute date/time values are stored internally as a 64-bit offset in seconds since the UNIX epoch (January 1, 1970 UTC), plus a 4-byte integer microseconds offset, plus a pointer to an AbstractQoreZoneInfo object, which gives the time zone information (UTC offset, daylights savings time transitions, if any, etc).

Therefore, for absolute date/time values, it is expensive to call functions that get discrete values for the date (DateTime::getYear(), DateTime::getMonth(), and DateTime::getDay()), because for each call, all broken-down components are calculated for each call. In the case that more than one component of an absolute date/time value is required, it's recommended to call DateTime::getInfo() instead.

Relative date/time values are stored with discrete values for years, months, days, hours, minutes, seconds, and microseconds.

This is a "normal" (i.e. not reference counted) class, for the equivalent Qore value type, see DateTimeNode

See also
DateTimeNode

Constructor & Destructor Documentation

◆ DateTime() [1/10]

DLLEXPORT DateTime::DateTime ( bool  r = false)

constructor for an empty object

Parameters
rsets the "relative" flag for the object

◆ DateTime() [2/10]

DLLEXPORT DateTime::DateTime ( int  n_year,
int  n_month,
int  n_day,
int  n_hour = 0,
int  n_minute = 0,
int  n_second = 0,
short  n_ms = 0,
bool  n_relative = false 
)

constructor for setting all parameters

note that for absolute date/time values, the local time zone will be assumed

Parameters
n_yearthe year value
n_monththe months value
n_daythe days value
n_hourthe hours value
n_minutethe minutes value
n_secondthe seconds value
n_msthe milliseconds value
n_relativethe relative flag

◆ DateTime() [3/10]

DLLEXPORT DateTime::DateTime ( int64  seconds)

constructor for setting an absolute date based on the number of seconds from January 1, 1970

note that the local time zone will be assumed

Parameters
secondsthe number of seconds from January 1, 1970

◆ DateTime() [4/10]

DLLEXPORT DateTime::DateTime ( int64  seconds,
int  ms 
)

constructor for setting an absolute date based on the number of seconds from January 1, 1970 (plus milliseconds)

note that the local time zone will be assumed

Parameters
secondsthe number of seconds from January 1, 1970
msthe milliseconds portion of the time

◆ DateTime() [5/10]

DLLEXPORT DateTime::DateTime ( const AbstractQoreZoneInfo *  zone,
const QoreValue  v 
)
explicit

constructor for creating an absolute date from a value representing a number of seconds

Parameters
zonetime zone for the date/time value, 0 = UTC,
See also
currentTZ()
Parameters
vthe value representing the number of seconds representing the offset from the epoch (1970-01-01)
Note
the zone argument is the assumed time zone for values without a specified time zone; for example, if the value is a string with a time zone specification then the zone argument is ignored

◆ DateTime() [6/10]

DLLEXPORT DateTime::DateTime ( const QoreValue  v)
explicit

constructor for creating a relative date from a value representing a number of seconds

Parameters
vthe value representing the number of seconds

◆ DateTime() [7/10]

DLLEXPORT DateTime::DateTime ( const char *  date)

constructor for setting the date from a string

Parameters
datethe string to use to set the date in the format YYYYMMDDHHmmSS[.xxx]

◆ DateTime() [8/10]

DLLEXPORT DateTime::DateTime ( const char *  date,
ExceptionSink xsink 
)

constructor for setting the date from a string with a flexible format, throws a Qore-language exception if the date string is invalid

Parameters
datethe string to use to set the date
xsinkany errors in the data string cause a Qore-language exception to be thrown here
Since
Qore 0.8.12.4

◆ DateTime() [9/10]

DLLEXPORT DateTime::DateTime ( const AbstractQoreZoneInfo *  zone,
const char *  date 
)

constructor for setting the date from a string with a flexible format

Parameters
zonethe time zone for the time (0 = UTC,
See also
currentTZ())
Parameters
datethe string to use to set the date

◆ DateTime() [10/10]

DLLEXPORT DateTime::DateTime ( const hashdecl tm *  tms)

constructor for setting an absolute date based on a "hashdecl tm"

Parameters
tmsa structure giving the absolute date to set

Member Function Documentation

◆ addSecondsTo()

DLLEXPORT void DateTime::addSecondsTo ( int64  secs,
int  us = 0 
)

adds the given number of seconds (and microseconds) to the date/time value

this is a very fast operation and particularly useful for date arithmentic on absolute date/time values

Parameters
secsthe number of seconds to add (a negative argument results in subtraction)
usthe number of microseconds to add (a negative argument results in subtraction)
Since
Qore 0.8.12

◆ format()

DLLEXPORT void DateTime::format ( QoreString str,
const char *  fmt 
) const

formats the date/time value to a QoreString

the formatted date/time value will be appended to the QoreString argument according to the format string Format codes are as follows:

  • YY: last two-digits of year
  • YYYY: four-digit year
  • M: month number (1-12)
  • MM: month number (1-12), zero padded
  • Month: long month string (ex: January)
  • MONTH: long month string capitalised (ex: JANUARY)
  • Mon: abbreviated month (ex: Jan)
  • MON: abbreviated month capitalised (ex: JAN)
  • D: day number (1 - 31)
  • DD: day number (1 - 31), zero padded
  • Day: long day of week string (ex: Monday)
  • DAY: long day of week string capitalised (ex: MONDAY)
  • Dy: abbreviated day of week string (ex: Mon)
  • DY: abbreviated day of week string capitalised (ex: MON)
  • H: hour number (0 - 23)
  • HH: hour number (00 - 23), zero padded
  • h: hour number (1 - 12)
  • hh: hour number (01 - 12), zero padded
  • m: minute number (0 - 59)
  • mm: minute number (00 - 59), zero padded
  • ms: milliseconds (000 - 999), zero padded (same as 'uu')
  • S: second number (0 - 59)
  • SS: second number (00 - 59), zero padded
  • u: milliseconds (0 - 999)
  • uu: milliseconds (000 - 999), zero padded (same as 'ms')
  • x: microseconds (0 - 999999)
  • xx: microseconds (000000 - 999999), zero padded
  • y: microseconds, with trailing zeros removed
  • z: local time zone name (ex: 'EST') if available, otherwise the UTC offset (see 'Z')
  • Z: UTC offset like +HH:mm[:SS], seconds are included if non-zero
  • P: AM or PM
  • p: am or pm
Note
currently locale settings are ignored
Parameters
strthe QoreString where the formatted date data will be written (appended)
fmtthe format string as per the above description

◆ getDateFromISOWeek()

static DLLEXPORT DateTime* DateTime::getDateFromISOWeek ( int  year,
int  week,
int  day,
ExceptionSink xsink 
)
static

returns a DateTime value from ISO-8601 week and day offsets

note that ISO-8601 week days go from 1 - 7 = Mon - Sun a 0 return value means an exception was raised

Parameters
yearthe year portion of the date in which the ISO-8601 week is found in
weekthe ISO-8601 week number
daythe day offset in the week (1-7 = Mon-Sun)
xsinkif an error occurs, the Qore-language exception information will be added here
Returns
the DateTime value corresponding to the ISO-8601 week information (or 0 if an error occured)

◆ getDay()

DLLEXPORT int DateTime::getDay ( ) const

returns the day portion of the date-time value (in local time according to the time zone for absolute date/time values)

Note
if more than one of DateTime::getYear(), DateTime::getMonth(), or DateTime::getDay() is called for an absolute date/time value, then DateTime::getInfo() should be used instead to avoid the broken-down components of the date being calculated for each call that retrieves a discrete value from the date. This restriction does not apply to relative date/time values.
Returns
the day portion of the date-time value

◆ getDayNumber()

DLLEXPORT int DateTime::getDayNumber ( ) const

returns the ordinal number of the day in the year for absolute dates, sometimes (mistakenly) referred to as the Julian date

does not return sensible values for relative dates

Returns
the number of the day in the year

◆ getDayOfWeek()

DLLEXPORT int DateTime::getDayOfWeek ( ) const

returns the day of week for the current date (0-6, Sun-Sat)

Returns
the day of week for the current date (0-6, Sun-Sat)

◆ getEpochMicrosecondsUTC()

DLLEXPORT int64 DateTime::getEpochMicrosecondsUTC ( ) const

gets the number of microseconds since January 1, 1970Z for the current date

Returns
the number of microseconds since January 1, 1970Z

◆ getEpochMillisecondsUTC()

DLLEXPORT int64 DateTime::getEpochMillisecondsUTC ( ) const

gets the number of milliseconds since January 1, 1970Z for the current date

Returns
the number of milliseconds since January 1, 1970Z

◆ getEpochSeconds()

DLLEXPORT int64 DateTime::getEpochSeconds ( ) const

gets the number of seconds since January 1, 1970 for the current date offset in local time

Returns
the number of seconds since January 1, 1970 offset in local time

◆ getEpochSecondsUTC()

DLLEXPORT int64 DateTime::getEpochSecondsUTC ( ) const

gets the number of seconds since January 1, 1970Z for the current date

Returns
the number of seconds since January 1, 1970Z

◆ getHour()

DLLEXPORT int DateTime::getHour ( ) const

returns the hour portion of the date-time value (in local time according to the time zone for absolute date/time values)

Note
DateTime::getHour() is calculated mathematically from the epoch offset for absolute date/time values, therefore it's much faster than DateTime::getYear(), DateTime::getMonth(), and DateTime::getDay(), however DateTime::getInfo() should be used if all date components are needed instead to avoid the broken-down components of the date being calculated for each call that retrieves a discrete value from the date
Returns
the hour portion of the date-time value

◆ getISOWeek()

DLLEXPORT void DateTime::getISOWeek ( int &  year,
int &  week,
int &  day 
) const

returns the ISO-8601 week information

NOTE: the year may be different than the actual year

Parameters
yearthe year portion of the ISO-9601 week information
weekthe ISO-9601 week number
daythe day offset in the week (1-7 = Mon-Sun)

◆ getMicrosecond()

DLLEXPORT int DateTime::getMicrosecond ( ) const

returns the microsecond portion of the date-time value

Returns
the microsecond portion of the date-time value

◆ getMillisecond()

DLLEXPORT int DateTime::getMillisecond ( ) const

returns the microsecond portion of the date-time value divided by 1000

Returns
the microsecond portion of the date-time value divided by 1000
See also
DateTime::getMicrosecond(), DateTime::getInfo()

◆ getMinute()

DLLEXPORT int DateTime::getMinute ( ) const

returns the minute portion of the date-time value (in local time according to the time zone for absolute date/time values)

Note
DateTime::getMinute() is calculated mathematically from the epoch offset for absolute date/time values, therefore it's much faster than DateTime::getYear(), DateTime::getMonth(), and DateTime::getDay(), however DateTime::getInfo() should be used if all date components are needed instead to avoid the broken-down components of the date being calculated for each call that retrieves a discrete value from the date
Returns
the minute portion of the date-time value

◆ getMonth()

DLLEXPORT int DateTime::getMonth ( ) const

returns the month portion of the date-time value (in local time according to the time zone for absolute date/time values)

Note
if more than one of DateTime::getYear(), DateTime::getMonth(), or DateTime::getDay() is called for an absolute date/time value, then DateTime::getInfo() should be used instead to avoid the broken-down components of the date being calculated for each call that retrieves a discrete value from the date. This restriction does not apply to relative date/time values.
Returns
the month portion of the date-time value

◆ getRelativeMicroseconds()

DLLEXPORT int64 DateTime::getRelativeMicroseconds ( ) const

returns the difference as the number of microseconds between the date/time value and the local time at the moment of the call, for absolute date/time values; for relative date/time values, the duration is converted to microseconds and returned as an integer

Returns
the difference as the number of microseconds between the date/time value and the local time at the moment of the call, for absolute date/time values; for relative date/time values, the duration is converted to microseconds and returned as an integer

◆ getRelativeMilliseconds()

DLLEXPORT int64 DateTime::getRelativeMilliseconds ( ) const

returns the difference as the number of milliseconds between the date/time value and the local time at the moment of the call, for absolute date/time values; for relative date/time values, the duration is converted to milliseconds and returned as an integer

Returns
the difference as the number of milliseconds between the date/time value and the local time at the moment of the call, for absolute date/time values; for relative date/time values, the duration is converted to milliseconds and returned as an integer

◆ getRelativeSeconds()

DLLEXPORT int64 DateTime::getRelativeSeconds ( ) const

returns the difference as the number of seconds between the date/time value and the local time at the moment of the call for absolute date/time values; for relative date/time values, the duration is converted to seconds and returned as an integer

Returns
the difference as the number of seconds between the date/time value and the local time at the moment of the call for absolute date/time values; for relative date/time values, the duration is converted to seconds and returned as an integer

◆ getRelativeSecondsDouble()

DLLEXPORT double DateTime::getRelativeSecondsDouble ( ) const

returns the difference as the number of seconds between the date/time value and the local time at the moment of the call for absolute date/time values; for relative date/time values, the duration is converted to seconds and returned as a floating-point value with fractional seconds as digits to the right of the decimal point

Returns
the difference as the number of seconds between the date/time value and the local time at the moment of the call for absolute date/time values; for relative date/time values, the duration is converted to seconds and returned as a floating-point value with fractional seconds as digits to the right of the decimal point

◆ getSecond()

DLLEXPORT int DateTime::getSecond ( ) const

returns the second portion of the date-time value (in local time according to the time zone for absolute date/time values)

Note
DateTime::getSecond() is calculated mathematically from the epoch offset for absolute date/time values, therefore it's much faster than DateTime::getYear(), DateTime::getMonth(), and DateTime::getDay(), however DateTime::getInfo() should be used if all date components are needed instead to avoid the broken-down components of the date being calculated for each call that retrieves a discrete value from the date
Returns
the second portion of the date-time value

◆ getYear()

DLLEXPORT short DateTime::getYear ( ) const

returns the year portion of the date-time value (in local time according to the time zone for absolute date/time values)

Note
if more than one of DateTime::getYear(), DateTime::getMonth(), or DateTime::getDay() is called, then DateTime::getInfo() should be used instead to avoid the broken-down components of the date being calculated for each call that retrieves a discrete value from the date. This restriction does not apply to relative date/time values.
Returns
the year portion of the date-time value

◆ isAbsolute()

DLLEXPORT bool DateTime::isAbsolute ( ) const

returns true if the value is an absolute date-time value

Returns
true if the value is an absolute date-time value

◆ isRelative()

DLLEXPORT bool DateTime::isRelative ( ) const

returns true if the value is a relative date-time value

Returns
true if the value is a relative date-time value

◆ makeAbsolute()

static DLLEXPORT DateTime* DateTime::makeAbsolute ( const AbstractQoreZoneInfo *  zone,
int64  seconds,
int  us = 0 
)
static

static "constructor" to create an absolute time as an offset from the epoch, including microseconds

Parameters
zonetime zone for the date/time value, 0 = UTC,
See also
currentTZ()
Parameters
secondsthe number of seconds from January 1, 1970Z
usthe microseconds portion of the time

◆ makeAbsoluteLocal()

static DLLEXPORT DateTime* DateTime::makeAbsoluteLocal ( const AbstractQoreZoneInfo *  zone,
int64  seconds,
int  us = 0 
)
static

static "constructor" to create an absolute time as an offset from the given time zone's epoch, including microseconds

Parameters
zonetime zone for the date/time value, 0 = UTC,
See also
currentTZ()
Parameters
secondsthe number of seconds from January 1, 1970 in the time zone passed as the first argument
usthe microseconds portion of the time

◆ setDate() [1/6]

DLLEXPORT void DateTime::setDate ( int64  seconds)

sets the absolute date value based on the number of seconds from January 1, 1970

note that the local time zone will be assumed

Parameters
secondsthe number of seconds from January 1, 1970

◆ setDate() [2/6]

DLLEXPORT void DateTime::setDate ( int64  seconds,
int  ms 
)

sets the absolute date value based on the number of seconds from January 1, 1970 UTC (plus milliseconds)

note that the local time zone will be assumed

Parameters
secondsthe number of seconds from January 1, 1970 UTC
msthe milliseconds portion of the time

◆ setDate() [3/6]

DLLEXPORT void DateTime::setDate ( const AbstractQoreZoneInfo *  zone,
int64  seconds,
int  us 
)

sets the absolute date value based on the number of seconds from January 1, 1970 UTC (plus microseconds)

Parameters
zonethe time zone for the time (0 = UTC,
See also
currentTZ())
Parameters
secondsthe number of seconds from January 1, 1970 UTC
usthe microseconds portion of the time

◆ setDate() [4/6]

DLLEXPORT void DateTime::setDate ( const char *  str)

sets an absolute date value from a string with a flexible format

note that the local time zone will be assumed

Parameters
strthe string to use to set the date

◆ setDate() [5/6]

DLLEXPORT void DateTime::setDate ( const char *  str,
ExceptionSink xsink 
)

sets an absolute date value from a string with a flexible format

note that the local time zone will be assumed

Parameters
strthe string to use to set the date
xsinkany errors in the data string cause a Qore-language exception to be thrown here
Since
Qore 0.8.12.4

◆ setDate() [6/6]

DLLEXPORT void DateTime::setDate ( const AbstractQoreZoneInfo *  zone,
const char *  str 
)

sets an absolute date value from a time zone pointer and a string with a flexible format

Parameters
zonethe time zone for the time (0 = UTC,
See also
currentTZ())
Parameters
strthe string to use to set the date with a flexible format

◆ setLocalDate()

DLLEXPORT void DateTime::setLocalDate ( const AbstractQoreZoneInfo *  zone,
int64  seconds,
int  us 
)

sets the absolute date value based on the number of seconds from January 1, 1970 in the given time zone (plus microseconds)

Parameters
zonethe time zone for the time (0 = UTC,
See also
currentTZ())
Parameters
secondsthe number of seconds from January 1, 1970 in the given time zone
usthe microseconds portion of the time

◆ setNow() [1/2]

DLLEXPORT void DateTime::setNow ( )

sets the current date and time in the current time zone; current contents are overwritten

Since
Qore 0.8.7

◆ setNow() [2/2]

DLLEXPORT void DateTime::setNow ( const AbstractQoreZoneInfo *  zone)

sets the current date and time in the given time zone; current contents are overwritten

Parameters
zonethe time zone for the time (0 = UTC,
See also
currentTZ())
Since
Qore 0.8.7

◆ setTime()

DLLEXPORT void DateTime::setTime ( int  h,
int  m,
int  s,
short  ms = 0 
)

sets the time from hours, minutes, seconds, and milliseconds

Parameters
hthe hours value
mthe minutes value
sthe seconds value
msthe milliseconds value

The documentation for this class was generated from the following file: