system.date - Palamecia/mint GitHub Wiki

Module

load system.date

This module provides the System.Date class which allow interactions with the system date and time for one specific System.TimeZone or for modification of the system date and time.

Packages

Classes

System.Date

This class provides informations about a specific timepoint.

Members

Modifiers Member Description
+ const != Returns false if the date described by other and this object are the same...
+ const == Returns true if the date described by other and this object are the same ...
+ const addDays Returns a new instance of System.Date containing a date ndays later than th...
+ const addHours Returns a new instance of System.Date containing a date nhours hours later ...
+ const addMilliseconds Returns a new instance of System.Date containing a date nmilliseconds milli...
+ const addMinutes Returns a new instance of System.Date containing a date nminutes minutes la...
+ const addMonths Returns a new instance of System.Date containing a date nmonths months late...
+ const addSeconds Returns a new instance of System.Date containing a date nseconds seconds la...
+ const addYears Returns a new instance of System.Date containing a date nyears years later ...
+ @ const current Returns the current date and time as an instance of System.Date.
+ @ const daysIn If month is specified, returns the number of days in the specified month fo...
+ const daysInMonth Returns the number of days in the month for this date.
+ const daysInYear Returns the number of days in the year for this date.
+ @ const epoch Global instance of System.Date for epoch (1970-01-01T00:00:00Z).
- @ g_lib Global library handle.
+ const getDay Returns the day of the month for this date.
+ const getHours Returns the hour part (0 to 23) of the time.
+ const getMilliseconds Returns the millisecond part (0 to 999) of the time.
+ const getMinutes Returns the minute part (0 to 59) of the time.
+ const getMonth Returns the month-number of this date. The month-number is a number between 1...
+ const getSeconds Returns the second part (0 to 59) of the time.
+ const getTimeZone Returns the instance of System.TimeZone used by this date.
+ const getWeekDay Returns the weekday of this date. The weekday is a number between 0 and 6 as ...
+ const getWeekNumber Returns the ISO 8601 week number (1 to 53).
+ const getYear Returns the year of this date.
+ const getYearDay Returns the day in the year of this date.
+ @ const isLeap Returns true if the specified year is a leap year; otherwise returns fa...
+ const isLeapYear Returns true if the year of this date is a leap year; otherwise returns f...
+ const new Creates a new instance for the current date and time with the current System....
+ @ const setCurrent Sets the system's current date and time to date. An instance of Exception.S...
+ const setDay Replace the day of the month of this date by day.
+ const setHours Replace the hour part of the time by hours.
+ const setMilliseconds Replace the millisecond part of the time by milliseconds.
+ const setMinutes Replace the minute part of the time by minutes.
+ const setMonth Replace the month-number of this date by month.
+ const setSeconds Replace the second part of the time by seconds.
+ const setTimeZone Sets the time zone used in this date to timezone. The timepoint of this dat...
+ const setYear Replace the year of this date by year.
- final timepoint Internal time point.
- final timezone Internal time zone.
+ const toMilliseconds Returns the date and time as the number of milliseconds that have passed sinc...
+ const toNumber Returns the date and time as the number of milliseconds that have passed sinc...
+ const toSeconds Returns the date and time as the number of seconds that have passed since epo...
+ const toString Returns the date as a string. The format parameter determines the format of...
~ const to_std_chrono_milliseconds Returns the pointer to the internal std::chrono::milliseconds instance.

Descriptions

System.Date.!=

def (const self, const other)

Returns false if the date described by other and this object are the same time point; otherwise returns true.

System.Date.==

def (const self, const other)

Returns true if the date described by other and this object are the same time point; otherwise returns false.

System.Date.addDays

def (self, ndays)

Returns a new instance of System.Date containing a date ndays later than the date of this object (or earlier if ndays is negative).

System.Date.addHours

def (self, nhours)

Returns a new instance of System.Date containing a date nhours hours later than the date of this object (or earlier if nhours is negative).

System.Date.addMilliseconds

def (self, nmilliseconds)

Returns a new instance of System.Date containing a date nmilliseconds milliseconds later than the date of this object (or earlier if nmilliseconds is negative).

System.Date.addMinutes

def (self, nminutes)

Returns a new instance of System.Date containing a date nminutes minutes later than the date of this object (or earlier if nminutes is negative).

System.Date.addMonths

def (self, nmonths)

Returns a new instance of System.Date containing a date nmonths months later than the date of this object (or earlier if nmonths is negative).

System.Date.addSeconds

def (self, nseconds)

Returns a new instance of System.Date containing a date nseconds seconds later than the date of this object (or earlier if nseconds is negative).

System.Date.addYears

def (self, nyears)

Returns a new instance of System.Date containing a date nyears years later than the date of this object (or earlier if nyears is negative).

System.Date.current

def ()

Returns the current date and time as an instance of System.Date.

System.Date.daysIn

def (year, month = none)

If month is specified, returns the number of days in the specified month for the year specified by year; otherwise returns the number of days in the year specified by year.

System.Date.daysInMonth

def (self)

Returns the number of days in the month for this date.

System.Date.daysInYear

def (self)

Returns the number of days in the year for this date.

System.Date.epoch

none

Global instance of System.Date for epoch (1970-01-01T00:00:00Z).

System.Date.g_lib

lib ('libmint-system')

Global library handle.

System.Date.getDay

def (const self)

Returns the day of the month for this date.

System.Date.getHours

def (const self)

Returns the hour part (0 to 23) of the time.

System.Date.getMilliseconds

def (const self)

Returns the millisecond part (0 to 999) of the time.

System.Date.getMinutes

def (const self)

Returns the minute part (0 to 59) of the time.

System.Date.getMonth

def (const self)

Returns the month-number of this date.

The month-number is a number between 1 and 12 as follow:

  • 1 = "January"
  • 2 = "February"
  • 3 = "March"
  • 4 = "April"
  • 5 = "May"
  • 6 = "June"
  • 7 = "July"
  • 8 = "August"
  • 9 = "September"
  • 10 = "October"
  • 11 = "November"
  • 12 = "December"

The System.Month enum can be used to check returned values.

System.Date.getSeconds

def (const self)

Returns the second part (0 to 59) of the time.

System.Date.getTimeZone

def (const self)

Returns the instance of System.TimeZone used by this date.

System.Date.getWeekDay

def (const self)

Returns the weekday of this date.

The weekday is a number between 0 and 6 as follow:

  • 0 = "Sunday"
  • 1 = "Monday"
  • 2 = "Tuesday"
  • 3 = "Wednesday"
  • 4 = "Thursday"
  • 5 = "Friday"
  • 6 = "Saturday"

The System.WeekDay enum can be used to check returned values.

System.Date.getWeekNumber

def (const self)

Returns the ISO 8601 week number (1 to 53).

System.Date.getYear

def (const self)

Returns the year of this date.

System.Date.getYearDay

def (const self)

Returns the day in the year of this date.

System.Date.isLeap

def (const year)

Returns true if the specified year is a leap year; otherwise returns false.

System.Date.isLeapYear

def (const self)

Returns true if the year of this date is a leap year; otherwise returns false.

System.Date.new

def (self)

Creates a new instance for the current date and time with the current System.TimeZone.

def (self, desc)

Creates a new instance for the date and time described by desc.

If desc is an instance of System.Date, this instance is returned.

If desc is a number, it is used as an unix timestamp to get the date and time (i.e. the amount of seconds since 1970-01-01T00:00:00Z). The current System.TimeZone is used.

If desc is a string, it is used as an ISO-8601 description of the date and time. The System.TimeZone is selected from the informations provided by the string or is UTC if not specified.

If desc provides a toDate method, this method is used to create the returned value; otherwise desc is cast to number to get an unix timestamp.

def (self, year, month, day, h = 0, min = 0, sec = 0, ms = 0, timezone = none)

Creates a new instance for the date and time described by the given parameters.

  • year is the year of the date and must be a number.
  • month is the month of the date and must be a number between 1 and 12.
  • day is the day of the date and must be a number between 1 and 31.
  • h is the amount of hours of the time and must be a number between 0 and 23.
  • min is the amount of minutes of the time and must be a number between 0 and 59.
  • sec is the amount of seconds of the time and must be a number between 0 and 60.
  • ms is the amount of milliseconds of the time and must be a number between 0 and 999.

This informations are expressed relativelty to the System.TimeZone described by the timezone parameter. The current System.TimeZone is used if the parameter is not provided. This instance is also used by the object.

System.Date.setCurrent

def (date)

Sets the system's current date and time to date.

An instance of Exception.SystemError is raised on error.

System.Date.setDay

def (self, day)

Replace the day of the month of this date by day.

System.Date.setHours

def (self, hours)

Replace the hour part of the time by hours.

System.Date.setMilliseconds

def (self, milliseconds)

Replace the millisecond part of the time by milliseconds.

System.Date.setMinutes

def (self, minutes)

Replace the minute part of the time by minutes.

System.Date.setMonth

def (self, month)

Replace the month-number of this date by month.

System.Date.setSeconds

def (self, seconds)

Replace the second part of the time by seconds.

System.Date.setTimeZone

def (self, timezone)

Sets the time zone used in this date to timezone. The timepoint of this date will remain unchanged but the date and time informations will be converted using the new time zone.

System.Date.setYear

def (self, year)

Replace the year of this date by year.

System.Date.timepoint

null

Internal time point.

System.Date.timezone

null

Internal time zone.

System.Date.toMilliseconds

def (const self)

Returns the date and time as the number of milliseconds that have passed since poch (1970-01-01T00:00:00.000Z).

System.Date.toNumber

def (const self)

Returns the date and time as the number of milliseconds that have passed since poch (1970-01-01T00:00:00.000Z).

System.Date.toSeconds

def (const self)

Returns the date and time as the number of seconds that have passed since epoch (1970-01-01T00:00:00Z).

System.Date.toString

def (const self, format = none, locale = none)

Returns the date as a string. The format parameter determines the format of the result string. The locale parameter is used to get the localized name for days and month.

If format is an instance of System.Locale, the format string is retrieved from a call to System.Locale.dateFormat. The locale parameter is ignored and this value is used instead.

If format is none, the format is retrieved from a call to System.Locale.dateFormat on the locale parameter. If the locale parameter is not provided, the locale retrieved by System.Locale.current is used instead.

In other cases, the format parameter is used as the format string. If the locale parameter is not provided, the locale retrieved by System.Locale.current is used instead.

The format string can use the following specifiers:

Specifier Output Example
%a Abbreviated weekday name Sun
%A Full weekday name Sunday
%b Abbreviated month name Mar
%B Full month name March
%c Date and time representation Sun Aug 19 02:56:02 2012
%d Day of the month (01-31) 19
%H Hour in 24h format (00-23) 14
%I Hour in 12h format (01-12) 05
%j Day of the year (001-366) 231
%m Month as a decimal number (01-12) 08
%M Minute (00-59) 55
%p AM or PM designation PM
%S Second (00-61) 02
%U Week number with the first Sunday as the first day of week one (00-53) 33
%w Weekday as a decimal number with Sunday as 0 (0-6) 4
%W Week number with the first Monday as the first day of week one (00-53) 34
%x Date representation 08/19/12
%X Time representation 02:50:06
%y Year, last two digits (00-99) 01
%Y Year 2012
%Z Timezone name or abbreviation CDT
%% A % sign %

System.Date.to_std_chrono_milliseconds

def (const self)

Returns the pointer to the internal std::chrono::milliseconds instance.