Class containing a calendar date and time broken down into its components. For convenience, all attributes has aliases to match struct tm provided in libc.
All class attributes are settable.
second ⇒ Integer
sec ⇒ Integer
tm_sec ⇒ Integer
-
Seconds after the minute. Can be modified.
minute ⇒ Integer
min ⇒ Integer
tm_min ⇒ Integer
-
Minutes after the hour. Can be modified.
hour ⇒ integer
tm_hour ⇒ integer
-
Hours since midnight. Can be modified.
day ⇒ Integer
mday ⇒ Integer
tm_mday ⇒ Integer
-
Day of the month. Can be modified.
month ⇒ Integer
mon ⇒ Integer
tm_mon ⇒ Integer
-
Months since January. Can be modified.
year ⇒ Integer
tm_year ⇒ Integer
-
Year. Can be modified.
dayOfYear ⇒ Integer
yday ⇒ Integer
tm_yday ⇒ Integer
-
Days since January 1. Can be modified.
dayOfWeek ⇒ Integer
wday ⇒ Integer
tm_wday ⇒ Integer
-
Days since Sunday. Can be modified.
isDST ⇒ Boolean
isdst ⇒ Boolean
tm_isdst ⇒ Boolean
-
Daylight Saving Time flag. Can be modified.
isUTC ⇒ Boolean
-
UTC flag. Can be modified.
timestamp ⇒ Integer
-
UNIX time (number of seconds since epoch). Can be modified.
format(format) ⇒ void
-
Formats a timestamp, and returns a string according to given formatting rules.
string |
String |
Formatting string - see this for available options http://www.cplusplus.com/reference/ctime/strftime/ |
Formatted time as a string.
time = DateTime(); println(time.format("%Y-%m-%d %H:%M")); //Will print: "2016-01-19 12:14" println(time.format("%Y-%m-%d %H:%M - timezone %Z - offset from UTC - %z")); //Will print: "2016-01-19 12:14 - timezone CET - offset from UTC - +0100"
DateTime()
-
Creates new DateTime object with current local time.
DateTime(timestamp)
-
Creates new DateTime with provided local time in UNIX time format.
timestamp |
Integer |
UNIX time (number of seconds since epoch). |
DateTime(time, isUTC)
-
Creates new DateTime object with provided time. Current time will be counted as UTC time if second parameter is true and as local time if second parameter is false.
timestamp |
Integer |
UNIX time (number of seconds since epoch). |
isUTC |
Boolean |
If provided time is in UTC. |