Prev: Module system: System Related Functions
Module time: Time and Date Functions
This module provides access to the real time clock. A given point in time in m
is always measured as the number of seconds since the beginning of year 0 (assuming the Gregorian calendar).
• function dayofweek(secs=time.get()) → Number
Gets the day of the week of the point in time defined by secs, according to the following table:
| 0||Monday |
• function get() → Number
Gets the local time in seconds since 0000-01-01 00:00:00. The numeric resolution is down to microseconds, but the actual resolution may be be coarser.
print str(time.get(), 1, 4)
See also: .date
• function set(secs) → null
Sets the local time in seconds since 0000-01-01 00:00:00 to secs.
time.set(time.get() + 60*60) // advance by 1 hour|
• function num(text, format="YMDhmst") → Number
Converts the string text into seconds since 0000-01-01 00:00:00, according to the format format.
The format string defines the order of the date and time parts in text. Each part finishes if either a character which is not a digit is encountered, or if the part's maximum length is reached. The parts are denoted by the following characters:
| Character||Max. length||Meaning |
| Y||4||Year. |
|h||2||Hour (24 hour representation). |
|t||3||Fraction of a second. |
One and two digit years are assumed to be in the 21st century, i.e. 2000 is added to them.
Throws ErrArgument if format contains a character other than those above.
print time.get(), time.num(date())|
→ 63279080895 63279080895
→ 2005-02-15 00:00:00
See also: time.str
• function str(secs, format="YYYY-MM-DD hh:mm:ss") → String
Converts the seconds since 0000-01-01 00:00:00 secs into a string, according to the format format.
Each character in the format string will be converted into a character in the resulting string, according to the following table:
| Y||Next digit of year |
|M||Next digit of month |
|D||Next digit of day |
|h||Next digit of hour |
|m||Next digit of minute |
|s||Next digit of second |
|t||Next digit of fractions of second |
The format is converted from right to left, except for t.
print date(), time.str(time.get())|
→ 2005-03-14 18:28:15 2005-03-14 18:28:15
print time.str(time.get(), "hh:mm:ss.ttt")
print time.str(time.get(), "DD.MM.YY")
See also: time.num, .date
• function utc() → Number
Gets the real time in the UTC (Universal Time Coordinate) time zone. This equals Greenwich local time, excluding any shift by daylight saving time.
The difference between local time and UTC time is the local time zone:
print time.get() - time.utc()|
• function weekofyear(secs=time.get()) → Number
Gets the week of the year of the point in time defined by secs. The first week in the year is the first week having four or more days in the year defined by secs.
Next: Module zip: ZIP Archives
© 2004-2011 airbit AG, CH-8008 Zürich