This message collects some Lua methods I found on the web for handling
dates and times.
See also in the Help file scriptable program commands that can also
handle dates and times under the Date Property Commands and Custom
Property Commands topics, as well as the ExpiryDateSupport and
Timestamp.lua scripts by Daniel Hertrich, downloadable from
<http://notecasepro.com/scripting.php>.
Date Formatting Functions
Lua-Users Wiki, Date Formatting Functions.
<http://lua-users.org/wiki/DateFormattingFunctions>.
A collection of functions for formatting dates in reports or
converting dates between different formats when importing data.
Day Of Week And Days In Month Example
Lua-Users Wiki, Day Of Week And Days In Month Example.
<http://lua-users.org/wiki/DayOfWeekAndDaysInMonthExample>. Date
functions that include calculating the number of days in a given month
and the day of week for a given calendar day.
See also Display Calendar In Html below, which includes a function for
extending the above examples to generate a calendar formatted as an
HTML table.
Display Calendar In Html
Lua-Users Wiki, Display Calendar in HTML,
<http://lua-users.org/wiki/DisplayCalendarInHtml>. Two functions for
generating a calendar formatted as an HTML table.
Finding the Right Date Format
Lua Forge, Finding the Right Date Format.
<http://snippets.luacode.org/snippets/Finding_the_right_date_format_103>.
A Lua script to look up date codes for use in fetching dates using
Lua's os.execute command.
Rosetta Code Lua Snippets
RosettaCode.org. Includes links to snippets for date handling:
Date format, <http://rosettacode.org/wiki/Date_format>
Date manipulation, <http://rosettacode.org/wiki/Date_manipulation>
Day of the week, <http://rosettacode.org/wiki/Day_of_the_week>
Leap year, <http://rosettacode.org/wiki/Leap_year>
Time Zone Function
Lua-Users Wiki, Time Zone, <http://lua-users.org/wiki/TimeZone>.
Platform-neutral Lua function that returns a timezone string in the
form +hhmm or -hhmm.
Unit Conversion Function
"This code provides a convert_to function that converts between any
two units on a scale defined in a table in pairs of {name, equivalent
number of previous unit}. The example given is time, but it can be
adapted for Imperial units, military divisions, pre-decimalisation
British pounds, or any other incremental system of measurement."
<http://lua-users.org/wiki/UnitConversion>
Best regards,
Paul
(And now I can put them in a library ;-) )
Regards
Gerard
You might also take a look at this project.
<http://luaforge.net/projects/date/>. It's described as follows on
LuaRocks:
"Pure Lua Date & Time module for Lua 5.x featuring date and Time
string parsing, time addition & subtraction, time span calculation,
support for ISO 8601 Dates, local time support, strftime-like
formatting. "
I haven't evaluated it.
Best regards,
Paul