webmcp

changeset 531:b19a6b4f61f3

Reject nonexistent dates in atom.date:new{...}
author jbe
date Mon Jan 15 20:13:32 2018 +0100 (2018-01-15)
parents 6dec66f8d48e
children 257dd2933ab2
files libraries/atom/atom.lua
line diff
     1.1 --- a/libraries/atom/atom.lua	Fri Dec 01 00:16:36 2017 +0100
     1.2 +++ b/libraries/atom/atom.lua	Mon Jan 15 20:13:32 2018 +0100
     1.3 @@ -770,10 +770,16 @@
     1.4          is_integer(month) and month >= 1 and month <= 12  and
     1.5          is_integer(day)   and day >= 1   and day <= 31
     1.6        then
     1.7 -        return date:_create{
     1.8 -          jd = date.ymd_to_jd(year, month, day),
     1.9 -          year = year, month = month, day = day
    1.10 -        }
    1.11 +        local jd = date.ymd_to_jd(year, month, day)
    1.12 +        local year2, month2, day2 = date.jd_to_ymd(jd)
    1.13 +        if year == year2 and month == month2 and day == day2 then
    1.14 +          return date:_create{
    1.15 +            jd = date.ymd_to_jd(year, month, day),
    1.16 +            year = year2, month = month2, day = day2
    1.17 +          }
    1.18 +        else
    1.19 +          return date.invalid
    1.20 +        end
    1.21        else
    1.22          return date.invalid
    1.23        end

Impressum / About Us