Date.lua: Difference between revisions
Line 34: | Line 34: | ||
==date_diff == | ==date_diff == | ||
'''INPUT:'''<BR> | |||
This library function required the following inputs/parameters. | |||
* Two dates as seconds to difference | |||
** Example: (546775200, 976708800) | |||
*** Thu Apr 30 10:00:00 UTC 1987, Wed Dec 13 12:00:00 UTC 2000 | |||
'''OUTPUT:'''<BR> | |||
This library function deliverers the following output/parameters. | |||
* A table | |||
** temp = { min=0, day=17, month=8,sec=0,hour=2, year=13} | |||
'''CODING EXAMPLE:''' | |||
-- Include/Call for this library | |||
require("date") | |||
temp = date.date_diff(546775200, 976708800) | |||
--temp will be valued as above. This will not be completely accurate in relation to leap years... | |||
==num_month_name == | ==num_month_name == |
Revision as of 15:11, 27 November 2007
date_to_seconds
INPUT:
This library function required the following inputs/parameters.
- Table of dates
- Example: t = { {year=2000,month=12,day=13}, {year=1987,month=4,day=30,hour=10}, {year=2020,month=1,day=10} }
OUTPUT:
This library function deliverers the following output/parameters.
- Sorted table of dates in seconds since 1970
- temp = { 546775200, 976708800, 1578657600 }
CODING EXAMPLE:
-- Include/Call for this library require("date") temp = date.date_to_seconds(t) --see table t above for a,b in ipairs(temp) do print(b) end --546775200 --976708800 --1578657600
seconds_to_date
INPUT:
This library function required the following inputs/parameters.
- Table of seconds since 1970
- Example: t = { 546775200, 976708800, 1578657600 }
OUTPUT:
This library function deliverers the following output/parameters.
- Will give a table with a formated string
- temp = { {Thu Apr 30 10:00:00 UTC 1987}, {Wed Dec 13 12:00:00 UTC 2000}, {Fri Jan 10 12:00:00 UTC 2020} }
CODING EXAMPLE:
-- Include/Call for this library require("date") temp = date.seconds_to_date(t) --see t above -- the formated string is found in the top of date.lua -- is format = "%a %b %d %X %Z %Y"
date_diff
INPUT:
This library function required the following inputs/parameters.
- Two dates as seconds to difference
- Example: (546775200, 976708800)
- Thu Apr 30 10:00:00 UTC 1987, Wed Dec 13 12:00:00 UTC 2000
- Example: (546775200, 976708800)
OUTPUT:
This library function deliverers the following output/parameters.
- A table
- temp = { min=0, day=17, month=8,sec=0,hour=2, year=13}
CODING EXAMPLE:
-- Include/Call for this library require("date") temp = date.date_diff(546775200, 976708800) --temp will be valued as above. This will not be completely accurate in relation to leap years...