| Vorlagenprogrammierung | Diskussionen | Lua | Test | Unterseiten | |||
| Modul | Deutsch | English
|
Modul: | Dokumentation | |||
DateTime – Module containing methods for the interpretation of date and time information, as well as computation, comparison and presentation.
The module is dedicated to tasks beyond parser functions #time and #timel capabilities.
Any unambiguous date formats in local area and English should be recognized as input.
Format a date/time value.
Parameters (all optional; whitespace around will be ignored):
now – now (Default)# provides number of seconds since 1st of January 1970 (UTC) – unix time. etc. will be treated as regular space.#timede default); de-AT and almost all languages with a Wikipedia assigned. On unknown language variant the basic language is native fallback. Letter casing will be ignored.#time (2nd parameter)1 day or 2 years ago as well as -5 months etc.tomorrow or yesterday as well as next Friday are possible only if 1 is related to now.#time a particular reference time is possible.#time on passing month and year termination by something else than even interval an unexpected result may arrive. Moreover, it is not clear what one month after May 31st is supposed to be.0 (default); 1 elseclass="error" will be presented.noerror=1 is an empty value the input has been invalid.Result: Formatted presentation.
These functions compare first and second parameter; as date or time input in any recognized format or now if not provided.
1, if condition is met, else “nothing”.In particular the functions mean:
lt – less thanle – less or equaleq – equalne – not equalge – greater or equalgt – greaterVersion ID: 2023-10-03
1 – required version, or keyword wikidataReturns:
2023-10-03) when wikidataThere are tests available to illustrate this in practice.
All of the above functions can be called from other Lua modules, if not Lua library function anyway. Use require(); the below code checks for errors loading it:
local lucky, DateTime = pcall( require, "Module:DateTime" )
if type( DateTime ) == "table" then
DateTime = DateTime.DateTime()
else
-- In the event of errors, DateTime is an error message.
return "<span class=\"error\">" .. DateTime .. "</span>"
end
This is a general library; use it anywhere.
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.