Add weekday to get_date_string

master
Wuzzy 2020-08-28 16:39:04 +02:00
parent 7ed6023d1b
commit 7f0e9f6e87
2 changed files with 5 additions and 2 deletions

2
API.md
View File

@ -102,6 +102,8 @@ Ordinal values:
Other:
* `%b`: Full name of current month
* `%h`: Short name of current month
* `%W`: Full name of current weekday
* `%w`: Short name of current weekday
* `%z`: Literal percent sign
### `calendar.register_holiday(def)`

View File

@ -142,6 +142,7 @@ calendar.get_date_string = function(format, total_days)
end
local y, m, d, j = calendar.get_date(total_days)
local w = calendar.get_weekday(total_days)
-- cardinal values
format = string.gsub( format, "%%Y", y ) -- elapsed years in epoch
@ -158,8 +159,8 @@ calendar.get_date_string = function(format, total_days)
format = string.gsub( format, "%%b", S(calendar.month_names[ m + 1 ]) ) -- current month long name
format = string.gsub( format, "%%h", S(calendar.month_names_short[ m + 1 ]) ) -- current month short name
format = string.gsub( format, "%%b", S(calendar.month_names[ m + 1 ]) ) -- current month long name
format = string.gsub( format, "%%h", S(calendar.month_names_short[ m + 1 ]) ) -- current month short name
format = string.gsub( format, "%%W", S(calendar.weekday_names[ w + 1 ]) ) -- current weekday long name
format = string.gsub( format, "%%w", S(calendar.weekday_names_short[ w + 1 ]) ) -- current weekday short name
format = string.gsub( format, "%%z", "%%" )