Avoid skipping a month if the day is 31 (#2028)
This commit is contained in:
parent
02f894ce0c
commit
35432e9f21
|
@ -216,9 +216,9 @@ function calendar_popup:call_calendar(offset, position, screen)
|
||||||
local raw_date = os.date("*t")
|
local raw_date = os.date("*t")
|
||||||
local date = {day=raw_date.day, month=raw_date.month, year=raw_date.year}
|
local date = {day=raw_date.day, month=raw_date.month, year=raw_date.year}
|
||||||
if widget._private.type == "month" and self.offset ~= 0 then
|
if widget._private.type == "month" and self.offset ~= 0 then
|
||||||
raw_date.month = raw_date.month + self.offset
|
local month_offset = (raw_date.month + self.offset - 1) % 12 + 1
|
||||||
raw_date = os.date("*t", os.time(raw_date))
|
local year_offset = raw_date.year + math.floor((raw_date.month + self.offset - 1) / 12)
|
||||||
date = {month=raw_date.month, year=raw_date.year}
|
date = {month=month_offset, year=year_offset }
|
||||||
elseif widget._private.type == "year" then
|
elseif widget._private.type == "year" then
|
||||||
date = {year=raw_date.year + self.offset}
|
date = {year=raw_date.year + self.offset}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue