Add calendar.get_total_days_from_date
parent
5cdfac7e3a
commit
980f3b9798
7
API.md
7
API.md
|
@ -66,6 +66,13 @@ Returns 4 values: days, months, years and days in year (in that order)
|
||||||
if `false`, use cardinal numbers
|
if `false`, use cardinal numbers
|
||||||
default: false
|
default: false
|
||||||
|
|
||||||
|
### `calendar.get_total_days_from_date(days, months, years, is_ordinal)`
|
||||||
|
Given a date, returns the total number of elapsed days (cardinal number).
|
||||||
|
|
||||||
|
* `days`/`months`/`years`: Date
|
||||||
|
* `is_ordinal`: If `true`, date is interpreted as ordinal numbers, otherwise
|
||||||
|
it is interpreted as cardinal numbers (default: `false`)
|
||||||
|
|
||||||
## `calendar.get_weekday(total_days)`
|
## `calendar.get_weekday(total_days)`
|
||||||
Returns cardinal weekday number for given day.
|
Returns cardinal weekday number for given day.
|
||||||
|
|
||||||
|
|
9
init.lua
9
init.lua
|
@ -143,6 +143,15 @@ calendar.get_date = function(total_days, ordinal)
|
||||||
return d, m, y, j
|
return d, m, y, j
|
||||||
end
|
end
|
||||||
|
|
||||||
|
calendar.get_total_days_from_date = function(days, months, years, is_ordinal)
|
||||||
|
if is_ordinal then
|
||||||
|
days = days - 1
|
||||||
|
months = months - 1
|
||||||
|
years = years - 1
|
||||||
|
end
|
||||||
|
return years * calendar.YEAR_DAYS + months * calendar.MONTH_DAYS + days
|
||||||
|
end
|
||||||
|
|
||||||
calendar.get_date_string = function(format, total_days)
|
calendar.get_date_string = function(format, total_days)
|
||||||
if not total_days then
|
if not total_days then
|
||||||
total_days = minetest.get_day_count()
|
total_days = minetest.get_day_count()
|
||||||
|
|
Loading…
Reference in New Issue