Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
UppHub
Status & Roadmap
FAQ
Authors & License
Forums
Funding U++
Search on this site











SourceForge.net Logo

SourceForge.net Logo

GitHub Logo

Discord Logo

Date

 

struct Date : public RelOpsDate, Moveable<Date> > 

A simple date object with up to a day precision.

 

 

Constructor detail

 

Date()

Default constructor.

 


 

Date(const Nuller&)

Construct an empty date.

 


 

Date(int y, int m, int d)

Constructs a date based on y m d.

 

 

Public Member List

 

byte day

Day.

 


 

byte month

Month.

 


 

int16 year

Year.

 


 

void Serialize(Stream& s)

Serializes Date to/from s.

 


 

bool IsValid() const

Returns true if the date is valid.

 


 

void Set(int scalar)

Assign a date that is stored in the numeric scalar.

 


 

int Get() const

Converts the time into a numeric value.

 


 

int Compare(Date bconst

Compares Date with b, returns -1 if <b, 0 if == b, 1 if > b.

 


 

Date& operator++()

Moves to the next day.

 


 

Date& operator--()

Moves to the previous day.

 


 

Date operator++(int)

Moves to the next day but returns the current (postfix++).

 


 

Date operator--(int)

Moves to the previous day but returns the current (postfix--).

 


 

static Date Low()

Returns the lowest possible date (year 4000).

 


 

static Date High()

Returns the highest possible date (year 4000).

 

 

Time

 

struct Time : public Date, public RelOpsTime, Moveable<Time> > 

A simple date time object with up to a second precision.

 

 

Constructor detail

 

Time()

Default constructor.

 


 

Time(const Nuller&)

Constructs an empty time.

 


 

Time(int y, int m, int d, int h = 0, int n = 0, int s = 0)

Constructs a time based on y m d h n s.

 


 

Time(FileTime filetime)

Constructs based on a platform specific filetime.

 

 

Public Member List

 

byte hour

Hour.

 


 

byte minute

Minute.

 


 

byte second

Second.

 


 

virtual static Time High()

Returns the highest possible time (year 4000).

 


 

virtual static Time Low()

Returns the lowest possible time (year -4000).

 


 

void Set(int64 scalar)

Assign a time that is stored in the numeric scalar.

 


 

virtual int64 Get() const

Converts the time into a numeric value.

 


 

bool IsValid() const

Returns true if Time is valid (Date is valid and hour/minute/second values are in range).

 


 

FileTime AsFileTime() const

Converts the time into a system specific value.

 

 

 

Date and Time functions

 

int DayOfWeek(Date date)

Day date number of day of week 0 Sunday - 6 Saturday.

 


 

bool IsLeapYear(int year)

Returns true if year is leap (there is 29 days in February in that year).

 


 

int GetDaysOfMonth(int month, int year)

Returns a number of days in month of year.

 


 

Date LastDayOfMonth(Date d)

Returns day d last day of the month.

Example:

     LastDayOfMonth(Date(2011, 9, 23)) = "30/9/2011"

 


 

Date FirstDayOfMonth(Date d)

Returns day d first day of the month.

Example:

     LastDayOfYear(Date(2011, 9, 23)) = "1/9/2011"

 


 

Date LastDayOfYear(Date d)

Returns day d last day of the year.

Example:

     LastDayOfYear(Date(2011, 9, 23)) = "31/12/2011"

 


 

Date FirstDayOfYear(Date d)

Returns day d first day of the year.

Example:

     FirstDayOfYear(Date(2011, 9, 23)) = "1/1/2011"

 


 

int DayOfYear(Date d)

Returns day d number of day of year, beginning from 1.

Example:

     DayOfYear(Date(2011, 1, 2)) = 2

 


 

Date AddMonths(Date date, int months)

Adds months to date and returns the result.

 


 

int GetMonths(Date since, Date till)

Number of months between two dates. Only whole months are counted.

Examples:

     GetMonths(Date(2013, 2, 5), Date(2013, 3, 4)) = 0

     GetMonths(Date(2013, 2, 5), Date(2013, 3, 5)) = 1

     GetMonths(Date(2013, 8, 31), Date(2013, 9, 30)) = 0

     GetMonths(Date(2013, 8, 31), Date(2013, 10, 1)) = 1

 


 

int GetMonthsP(Date since, Date till)

Number of months between two dates, including partial months.

Examples:

     GetMonthsP(Date(2016, 1, 1), Date(2016, 1, 1)) = 0

     GetMonthsP(Date(2016, 1, 1), Date(2016, 1, 2)) = 1 // partial

     GetMonthsP(Date(2016, 1, 1), Date(2016, 2, 1)) = 1 // exact one

     GetMonthsP(Date(2016, 1, 1), Date(2016, 2, 2)) = 2 // partial 2nd

 


 

Date AddYears(Date date, int years)

Adds years to date and returns the result. Note that this is not as simple as adding year attribute of Date because of leap years.

 


 

Date GetWeekDate(int year, int week)

Returns the date of Monday for given year and week according to ISO-8601. (First week of year is 1).

 


 

int GetWeek(Date d, int& year)

Returns the week for given date according to ISO-8601. In year the corresponding year is returned, as some days at the beginning or end of the year can be part of week of another week.

 


 

Date EasterDay(int year)

Returns the Easter day for given year.

 


 

int GetTimeZone()

Returns a local timezone as offset from GMT in minutes.

 


 

String FormatTimeZone(int n)

Formats timezone in common format, used e.g. in internet dates.

 


 

String GetTimeZoneText()

Same as FormatTimeZone(GetTimeZone()).

 


 

int ScanTimeZone(const char *s)

Scans timezone text to obtain offset in seconds.

 


 

int GetLeapSeconds(Date dt)

Returns the number of leap seconds that has occurred since the start of adding leap seconds till dt.

 


 

int64 GetUTCSeconds(Time tm)

Returns the number of seconds since 1970-1-1, including leap seconds.

 


 

Time TimeFromUTC(int64 seconds)

Converts seconds since 1970-1-1, with leap seconds included, to Time.

 

 

Do you want to contribute?