Home
Base module

LocalDateTime

This class represents an instant in local time (as opposed to UTC), expressed in years, months, days, hours, minutes, seconds and milliseconds based on the Gregorian calendar.

LocalDateTime

#include <icy/datetime.h>
class LocalDateTime

Defined in src/base/include/icy/datetime.h:703

This class represents an instant in local time (as opposed to UTC), expressed in years, months, days, hours, minutes, seconds and milliseconds based on the Gregorian calendar.

In addition to the date and time, the class also maintains a time zone differential, which denotes the difference in seconds from UTC to local time, i.e. UTC = local time - time zone differential.

Although LocalDateTime supports relational and arithmetic operators, all date/time comparisons and date/time arithmetics should be done in UTC, using the DateTime or Timestamp class for better performance. The relational operators normalize the dates/times involved to UTC before carrying out the comparison.

The time zone differential is based on the input date and time and current time zone. A number of constructors accept an explicit time zone differential parameter. These should not be used since daylight savings time processing is impossible since the time zone is unknown. Each of the constructors accepting a tzd parameter have been marked as deprecated and may be removed in a future revision.

List of all members

NameKindOwner
DateTimeFormatterfriendDeclared here
DateTimeParserfriendDeclared here
LocalDateTimefunctionDeclared here
LocalDateTimefunctionDeclared here
LocalDateTimefunctionDeclared here
LocalDateTimefunctionDeclared here
LocalDateTimefunctionDeclared here
LocalDateTimefunctionDeclared here
LocalDateTimefunctionDeclared here
LocalDateTimefunctionDeclared here
LocalDateTimefunctionDeclared here
~LocalDateTimefunctionDeclared here
operator=functionDeclared here
operator=functionDeclared here
operator=functionDeclared here
assignfunctionDeclared here
assignfunctionDeclared here
assignfunctionDeclared here
swapfunctionDeclared here
yearfunctionDeclared here
monthfunctionDeclared here
weekfunctionDeclared here
dayfunctionDeclared here
dayOfWeekfunctionDeclared here
dayOfYearfunctionDeclared here
hourfunctionDeclared here
hourAMPMfunctionDeclared here
isAMfunctionDeclared here
isPMfunctionDeclared here
minutefunctionDeclared here
secondfunctionDeclared here
millisecondfunctionDeclared here
microsecondfunctionDeclared here
julianDayfunctionDeclared here
tzdfunctionDeclared here
utcfunctionDeclared here
timestampfunctionDeclared here
utcTimefunctionDeclared here
operator==functionDeclared here
operator!=functionDeclared here
operator<functionDeclared here
operator<=functionDeclared here
operator>functionDeclared here
operator>=functionDeclared here
operator+functionDeclared here
operator-functionDeclared here
operator-functionDeclared here
operator+=functionDeclared here
operator-=functionDeclared here
LocalDateTimefunctionDeclared here
determineTzdfunctionDeclared here
adjustForTzdfunctionDeclared here
dstOffsetfunctionDeclared here
_dateTimevariableDeclared here
_tzdvariableDeclared here

Friends


DateTimeFormatter

friend class DateTimeFormatter

Defined in src/base/include/icy/datetime.h:919


DateTimeParser

friend class DateTimeParser

Defined in src/base/include/icy/datetime.h:920

Public Methods

ReturnNameDescription
LocalDateTimeCreates a LocalDateTime with the current date/time for the current time zone.
LocalDateTimeCreates a LocalDateTime for the given Gregorian local date and time.
LocalDateTime@ deprecated Creates a LocalDateTime for the given Gregorian date and time in the time zone denoted by the time zone differential in tzd.
LocalDateTimeCreates a LocalDateTime from the UTC time given in dateTime, using the time zone differential of the current time zone.
LocalDateTime@ deprecated Creates a LocalDateTime from the UTC time given in dateTime, using the given time zone differential. Adjusts dateTime for the given time zone differential.
LocalDateTime@ deprecated Creates a LocalDateTime from the UTC time given in dateTime, using the given time zone differential. If adjust is true, adjusts dateTime for the given time zone differential.
LocalDateTimeCreates a LocalDateTime for the given Julian day in the local time zone.
LocalDateTime@ deprecated Creates a LocalDateTime for the given Julian day in the time zone denoted by the time zone differential in tzd.
LocalDateTimeCopy constructor. Creates the LocalDateTime from another one.
~LocalDateTimeDestroys the LocalDateTime.
LocalDateTime &operator=Assigns another LocalDateTime.
LocalDateTime &operator=Assigns a timestamp.
LocalDateTime &operator=Assigns a Julian day in the local time zone.
LocalDateTime &assignAssigns a Gregorian local date and time.
LocalDateTime &assign@ deprecated Assigns a Gregorian local date and time in the time zone denoted by the time zone differential in tzd.
LocalDateTime &assign@ deprecated Assigns a Julian day in the time zone denoted by the time zone differential in tzd.
voidswapSwaps the LocalDateTime with another one.
intyear const inlineReturns the year.
intmonth const inlineReturns the month (1 to 12).
intweek const inlineReturns the week number within the year. FirstDayOfWeek should be either SUNDAY (0) or MONDAY (1). The returned week number will be from 0 to 53. Week number 1 is the week containing January 4. This is in accordance to ISO 8601.
intday const inlineReturns the day witin the month (1 to 31).
intdayOfWeek const inlineReturns the weekday (0 to 6, where 0 = Sunday, 1 = Monday, ..., 6 = Saturday).
intdayOfYear const inlineReturns the number of the day in the year. January 1 is 1, February 1 is 32, etc.
inthour const inlineReturns the hour (0 to 23).
inthourAMPM const inlineReturns the hour (0 to 12).
boolisAM const inlineReturns true if hour < 12;.
boolisPM const inlineReturns true if hour >= 12.
intminute const inlineReturns the minute (0 to 59).
intsecond const inlineReturns the second (0 to 59).
intmillisecond const inlineReturns the millisecond (0 to 999)
intmicrosecond const inlineReturns the microsecond (0 to 999)
doublejulianDay const inlineReturns the julian day for the date.
inttzd const inlineReturns the time zone differential.
DateTimeutc constReturns the UTC equivalent for the local date and time.
Timestamptimestamp const inlineReturns the date and time expressed as a Timestamp.
Timestamp::UtcTimeValutcTime const inlineReturns the UTC equivalent for the local date and time.
booloperator== const
booloperator!= const
booloperator< const
booloperator<= const
booloperator> const
booloperator>= const
LocalDateTimeoperator+ const
LocalDateTimeoperator- const
Timespanoperator- const
LocalDateTime &operator+=
LocalDateTime &operator-=

LocalDateTime

LocalDateTime()

Defined in src/base/include/icy/datetime.h:708

Creates a LocalDateTime with the current date/time for the current time zone.


LocalDateTime

LocalDateTime(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0)

Defined in src/base/include/icy/datetime.h:719

Creates a LocalDateTime for the given Gregorian local date and time.

  • year is from 0 to 9999.

  • month is from 1 to 12.

  • day is from 1 to 31.

  • hour is from 0 to 23.

  • minute is from 0 to 59.

  • second is from 0 to 59.

  • millisecond is from 0 to 999.

  • microsecond is from 0 to 999.


LocalDateTime

LocalDateTime(int tzd, int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond)

Defined in src/base/include/icy/datetime.h:734

@ deprecated Creates a LocalDateTime for the given Gregorian date and time in the time zone denoted by the time zone differential in tzd.

  • tzd is in seconds.

  • year is from 0 to 9999.

  • month is from 1 to 12.

  • day is from 1 to 31.

  • hour is from 0 to 23.

  • minute is from 0 to 59.

  • second is from 0 to 59.

  • millisecond is from 0 to 999.

  • microsecond is from 0 to 999.


LocalDateTime

LocalDateTime(const DateTime & dateTime)

Defined in src/base/include/icy/datetime.h:739

Creates a LocalDateTime from the UTC time given in dateTime, using the time zone differential of the current time zone.


LocalDateTime

LocalDateTime(int tzd, const DateTime & dateTime)

Defined in src/base/include/icy/datetime.h:745

@ deprecated Creates a LocalDateTime from the UTC time given in dateTime, using the given time zone differential. Adjusts dateTime for the given time zone differential.


LocalDateTime

LocalDateTime(int tzd, const DateTime & dateTime, bool adjust)

Defined in src/base/include/icy/datetime.h:752

@ deprecated Creates a LocalDateTime from the UTC time given in dateTime, using the given time zone differential. If adjust is true, adjusts dateTime for the given time zone differential.


LocalDateTime

LocalDateTime(double julianDay)

Defined in src/base/include/icy/datetime.h:755

Creates a LocalDateTime for the given Julian day in the local time zone.


LocalDateTime

LocalDateTime(int tzd, double julianDay)

Defined in src/base/include/icy/datetime.h:761

@ deprecated Creates a LocalDateTime for the given Julian day in the time zone denoted by the time zone differential in tzd.


LocalDateTime

LocalDateTime(const LocalDateTime & dateTime)

Defined in src/base/include/icy/datetime.h:764

Copy constructor. Creates the LocalDateTime from another one.


~LocalDateTime

~LocalDateTime()

Defined in src/base/include/icy/datetime.h:767

Destroys the LocalDateTime.


operator=

LocalDateTime & operator=(const LocalDateTime & dateTime)

Defined in src/base/include/icy/datetime.h:770

Assigns another LocalDateTime.


operator=

LocalDateTime & operator=(const Timestamp & timestamp)

Defined in src/base/include/icy/datetime.h:773

Assigns a timestamp.


operator=

LocalDateTime & operator=(double julianDay)

Defined in src/base/include/icy/datetime.h:776

Assigns a Julian day in the local time zone.


assign

LocalDateTime & assign(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microseconds = 0)

Defined in src/base/include/icy/datetime.h:787

Assigns a Gregorian local date and time.

  • year is from 0 to 9999.

  • month is from 1 to 12.

  • day is from 1 to 31.

  • hour is from 0 to 23.

  • minute is from 0 to 59.

  • second is from 0 to 59.

  • millisecond is from 0 to 999.

  • microsecond is from 0 to 999.


assign

LocalDateTime & assign(int tzd, int year, int month, int day, int hour, int minute, int second, int millisecond, int microseconds)

Defined in src/base/include/icy/datetime.h:803

@ deprecated Assigns a Gregorian local date and time in the time zone denoted by the time zone differential in tzd.

  • tzd is in seconds.

  • year is from 0 to 9999.

  • month is from 1 to 12.

  • day is from 1 to 31.

  • hour is from 0 to 23.

  • minute is from 0 to 59.

  • second is from 0 to 59.

  • millisecond is from 0 to 999.

  • microsecond is from 0 to 999.


assign

LocalDateTime & assign(int tzd, double julianDay)

Defined in src/base/include/icy/datetime.h:810

@ deprecated Assigns a Julian day in the time zone denoted by the time zone differential in tzd.


swap

void swap(LocalDateTime & dateTime)

Defined in src/base/include/icy/datetime.h:813

Swaps the LocalDateTime with another one.


year

const inline

inline int year() const

Defined in src/base/include/icy/datetime.h:816

Returns the year.


month

const inline

inline int month() const

Defined in src/base/include/icy/datetime.h:819

Returns the month (1 to 12).


week

const inline

inline int week(int firstDayOfWeek = DateTime::MONDAY) const

Defined in src/base/include/icy/datetime.h:835

Returns the week number within the year. FirstDayOfWeek should be either SUNDAY (0) or MONDAY (1). The returned week number will be from 0 to 53. Week number 1 is the week containing January 4. This is in accordance to ISO 8601.

The following example assumes that firstDayOfWeek is MONDAY. For 2005, which started on a Saturday, week 1 will be the week starting on Monday, January 3. January 1 and 2 will fall within week 0 (or the last week of the previous year).

For 2007, which starts on a Monday, week 1 will be the week startung on Monday, January 1. There will be no week 0 in 2007.


day

const inline

inline int day() const

Defined in src/base/include/icy/datetime.h:838

Returns the day witin the month (1 to 31).


dayOfWeek

const inline

inline int dayOfWeek() const

Defined in src/base/include/icy/datetime.h:842

Returns the weekday (0 to 6, where 0 = Sunday, 1 = Monday, ..., 6 = Saturday).


dayOfYear

const inline

inline int dayOfYear() const

Defined in src/base/include/icy/datetime.h:846

Returns the number of the day in the year. January 1 is 1, February 1 is 32, etc.


hour

const inline

inline int hour() const

Defined in src/base/include/icy/datetime.h:849

Returns the hour (0 to 23).


hourAMPM

const inline

inline int hourAMPM() const

Defined in src/base/include/icy/datetime.h:852

Returns the hour (0 to 12).


isAM

const inline

inline bool isAM() const

Defined in src/base/include/icy/datetime.h:855

Returns true if hour < 12;.


isPM

const inline

inline bool isPM() const

Defined in src/base/include/icy/datetime.h:858

Returns true if hour >= 12.


minute

const inline

inline int minute() const

Defined in src/base/include/icy/datetime.h:861

Returns the minute (0 to 59).


second

const inline

inline int second() const

Defined in src/base/include/icy/datetime.h:864

Returns the second (0 to 59).


millisecond

const inline

inline int millisecond() const

Defined in src/base/include/icy/datetime.h:867

Returns the millisecond (0 to 999)


microsecond

const inline

inline int microsecond() const

Defined in src/base/include/icy/datetime.h:870

Returns the microsecond (0 to 999)


julianDay

const inline

inline double julianDay() const

Defined in src/base/include/icy/datetime.h:873

Returns the julian day for the date.


tzd

const inline

inline int tzd() const

Defined in src/base/include/icy/datetime.h:876

Returns the time zone differential.


utc

const

DateTime utc() const

Defined in src/base/include/icy/datetime.h:879

Returns the UTC equivalent for the local date and time.


timestamp

const inline

inline Timestamp timestamp() const

Defined in src/base/include/icy/datetime.h:882

Returns the date and time expressed as a Timestamp.


utcTime

const inline

inline Timestamp::UtcTimeVal utcTime() const

Defined in src/base/include/icy/datetime.h:885

Returns the UTC equivalent for the local date and time.


operator==

const

bool operator==(const LocalDateTime & dateTime) const

Defined in src/base/include/icy/datetime.h:887


operator!=

const

bool operator!=(const LocalDateTime & dateTime) const

Defined in src/base/include/icy/datetime.h:888


operator<

const

bool operator<(const LocalDateTime & dateTime) const

Defined in src/base/include/icy/datetime.h:889


operator<=

const

bool operator<=(const LocalDateTime & dateTime) const

Defined in src/base/include/icy/datetime.h:890


operator>

const

bool operator>(const LocalDateTime & dateTime) const

Defined in src/base/include/icy/datetime.h:891


operator>=

const

bool operator>=(const LocalDateTime & dateTime) const

Defined in src/base/include/icy/datetime.h:892


operator+

const

LocalDateTime operator+(const Timespan & span) const

Defined in src/base/include/icy/datetime.h:894


operator-

const

LocalDateTime operator-(const Timespan & span) const

Defined in src/base/include/icy/datetime.h:895


operator-

const

Timespan operator-(const LocalDateTime & dateTime) const

Defined in src/base/include/icy/datetime.h:896


operator+=

LocalDateTime & operator+=(const Timespan & span)

Defined in src/base/include/icy/datetime.h:897


operator-=

LocalDateTime & operator-=(const Timespan & span)

Defined in src/base/include/icy/datetime.h:898

Protected Methods

ReturnNameDescription
LocalDateTime
voiddetermineTzdRecalculate the tzd based on the _dateTime member based on the current timezone using the Standard C runtime functions. If adjust is true, then adjustForTzd() is called after the differential is calculated.
voidadjustForTzd inlineAdjust the _dateTime member based on the _tzd member.
std::time_tdstOffset constDetermine the DST offset for the current date/time.

LocalDateTime

LocalDateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff, int tzd)

Defined in src/base/include/icy/datetime.h:901


determineTzd

void determineTzd(bool adjust = false)

Defined in src/base/include/icy/datetime.h:907

Recalculate the tzd based on the _dateTime member based on the current timezone using the Standard C runtime functions. If adjust is true, then adjustForTzd() is called after the differential is calculated.


adjustForTzd

inline

inline void adjustForTzd()

Defined in src/base/include/icy/datetime.h:910

Adjust the _dateTime member based on the _tzd member.


dstOffset

const

std::time_t dstOffset(int & dstOffset) const

Defined in src/base/include/icy/datetime.h:913

Determine the DST offset for the current date/time.

Private Attributes

ReturnNameDescription
DateTime_dateTime
int_tzd

_dateTime

DateTime _dateTime

Defined in src/base/include/icy/datetime.h:916


_tzd

int _tzd

Defined in src/base/include/icy/datetime.h:917