Module pl.Date

Date and Date Format classes.

See the Guide.

Functions

Date (t) Date constructor.
Date:set (t) set the current time of this Date object.
Date:year (y) set the year.
Date:month (m) set the month.
Date:day (d) set the day.
Date:hour (h) set the hour.
Date:min (min) set the minutes.
Date:sec (sec) set the seconds.
Date:yday (yday) set the day of year.
Date:year (y) get the year.
Date:month () get the month.
Date:day () get the day.
Date:hour () get the hour.
Date:min () get the minutes.
Date:sec () get the seconds.
Date:yday () get the day of year.
Date:weekday_name (full) name of day of week.
Date:month_name (full) name of month.
Date:is_weekend () is this day on a weekend?.
Date:add (t) add to a date object.
Date:last_day () last day of the month.
Date:diff (other) difference between two Date objects.
Date:__tostring () long numerical ISO data format version of this date.
Date:__eq (other) equality between Date objects.
Date:__lt (other) equality between Date objects.
Date.Format (fmt.) Date.Format constructor.
Date.Format:parse (str) parse a string into a Date object.
Date.Format:tostring (d) convert a Date object into a string.


Functions

Date (t)
Date constructor.

Parameters:

  • t: this can be either
    • nil - use current date and time
    • number - seconds since epoch (as returned by os.time())
    • Date - copy constructor
    • table - table containing year, month, etc as for os.time()
Date:set (t)
set the current time of this Date object.

Parameters:

  • t: seconds since epoch
Date:year (y)
set the year.

Parameters:

  • y: Four-digit year
Date:month (m)
set the month.

Parameters:

  • m: month
Date:day (d)
set the day.

Parameters:

  • d: day
Date:hour (h)
set the hour.

Parameters:

  • h: hour
Date:min (min)
set the minutes.

Parameters:

  • min: minutes
Date:sec (sec)
set the seconds.

Parameters:

  • sec: seconds
Date:yday (yday)
set the day of year.

Parameters:

  • yday: day of year
Date:year (y)
get the year.

Parameters:

  • y: Four-digit year
Date:month ()
get the month.
Date:day ()
get the day.
Date:hour ()
get the hour.
Date:min ()
get the minutes.
Date:sec ()
get the seconds.
Date:yday ()
get the day of year.
Date:weekday_name (full)
name of day of week.

Parameters:

  • full: abbreviated if true, full otherwise.
Date:month_name (full)
name of month.

Parameters:

  • full: abbreviated if true, full otherwise.
Date:is_weekend ()
is this day on a weekend?.
Date:add (t)
add to a date object.

Parameters:

  • t: a table containing one of the following keys and a value:
    year,month,day,hour,min,sec
Date:last_day ()
last day of the month.
Date:diff (other)
difference between two Date objects.

Parameters:

  • other: Date object

Returns:

    a Date object
Date:__tostring ()
long numerical ISO data format version of this date.
Date:__eq (other)
equality between Date objects.

Parameters:

  • other:
Date:__lt (other)
equality between Date objects.

Parameters:

  • other:
Date.Format (fmt.)
Date.Format constructor.

Parameters:

  • fmt.: A string where the following fields are significant:
    • d day (either d or dd)
    • y year (either yy or yyy)
    • m month (either m or mm)
    • H hour (either H or HH)
    • M minute (either M or MM)
    • S second (either S or SS)

Usage:

    df = Date.Format("yyyy-mm-dd HH:MM:SS")
Date.Format:parse (str)
parse a string into a Date object.

Parameters:

  • str: a date string

Returns:

    date object
Date.Format:tostring (d)
convert a Date object into a string.

Parameters:

  • d: a date object

Returns:

    string