- Project details
LibDateTime
LibDateTime provide locale date and time, formatting function, clock callback and more DateTime functions. This library is localized in English, French, German, Spanish and Italian.
This library can be include in another addon.
Documentation
DateTime type :
This is a table with following format and support{
year = 2008,
month = 9,
day = 12,
hour = 12,
minute = 0,
second = 0
}
LibDateTime:New(year, month, day, hour, minute, second)
Returns a DateTime table.
- year: a number (default: 1970)
- month: a number (default: 1)
- day: a number (default: 1)
- hour: a number (default: 0)
- minute: a number (default: 0)
- second: a number (default: 0)
LibDateTime:Now()
Returns current DateTime.
LibDateTime:GameStartedSince()
Returns the number of seconds since the game begin.
LibDateTime:IsLeapYear(year)
Return true if year is a leap year.
LibDateTime:YearDay(datetime)
Returns a number representing the day of the year (1..366).
- datetime: a DateTime table
LibDateTime:WeekDay(datetime)
Returns week day number (1..7 => Mon..Sun).
- datetime: a DateTime table
LibDateTime:Format(datetime, format)
Returns formatted DateTime.
- datetime: a DateTime table
- format: a format string
- Code to use in format string:
- %a - The abbreviated weekday name (``Sun)
- %A - The full weekday name (``Sunday)
- %b - The abbreviated month name (``Jan)
- %B - The full month name (``January)
- %d - Day of the month (01..31)
- %H - Hour of the day, 24-hour clock (00..23)
- %I - Hour of the day, 12-hour clock (01..12)
- %j - Day of the year (001..366)
- %m - Month of the year (01..12)
- %M - Minute of the hour (00..59)
- %p - Meridian indicator (``AM or ``PM)
- %S - Second of the minute (00..60)
- %w - Day of the week (Sunday is 0, 0..6)
- %y - Year without a century (00..99)
- %Y - Year with century
- %% - Literal ``% character
LibDateTime.Format(datetime, "%d/%m/%Y %H:%M:%S") => "12/09/2008 12:00:00" LibDateTime.Format(datetime, "%Y-%m-%d %H:%M:%S") => "2008-09-19 12:00:00"
LibDateTime:DateTime2UnixTime(datetime)
Convert a `DateTime' to unix time.
- datetime: a DateTime table
LibDateTime:RegisterClock(callback)
Register a clock function to call every second when DateTime is updated. Return handle string if successful registered, or false if not. The callback method receive a DateTime table in argument.
- callback: is a function or a string (function name)
LibDateTime.RegisterClock(MyMod.MyClockFunction)
LibDateTime.RegisterClock("MyMod.MyClockFunction")
LibDateTime:UnRegisterClock(handle)
Unregister the clock responding to handle string (returned by LibDateTime.RegisterClock).
handle: a handle string
LibDateTime:IsInitialized()
Returns true if LibDateTime is initialized
- Facts
| Date created: | 13 Oct 2008 |
|---|---|
| Category: | Development Tools |
| Last Update: | 19 Nov 2008 |
| Language: |
|
| License: | Public Domain |
| Curse Project: | LibDateTime |
- Authors
| R | release-0.4.7 | WAR: Beta 3.0 | 19 Nov 2008 |
| R | release-0.4.6 | WAR: Beta 3.0 | 15 Nov 2008 |
| R | release-0.4.4 | WAR: Beta 3.0 | 15 Nov 2008 |
| B | beta-0.4.3 | WAR: Beta 3.0 | 26 Oct 2008 |
| B | beta-0.4.2 | WAR: Beta 3.0 | 23 Oct 2008 |

Be the first to comment!