「モジュール:ヨーグレキ」の版間の差分

ヨーグ前に対応
(他モジュールから使いたくなった)
(ヨーグ前に対応)
 
(同じ利用者による、間の1版が非表示)
19行目: 19行目:


local function isYogurianValidDate(yYear, yMonth, yDay)
local function isYogurianValidDate(yYear, yMonth, yDay)
     return yMonth > 0 and yMonth <= 12 and yDay > 0 and yDay <= 30 +
     return yYear ~= 0 and yMonth > 0 and yMonth <= 12 and yDay > 0 and yDay <= 30 +
               (yMonth == 1 and (isLeap(yYear + 2020) and 6 or 5) or 0)
               (yMonth == 1 and (isLeap(yYear + 2020) and 6 or 5) or 0)
end
end
67行目: 67行目:
     ym = dfn <= hmd and 1 or math.floor((dfn - hmd - 1) / 30) + 2
     ym = dfn <= hmd and 1 or math.floor((dfn - hmd - 1) / 30) + 2
     yd = ym == 1 and dfn or (dfn - hmd - 1) % 30 + 1
     yd = ym == 1 and dfn or (dfn - hmd - 1) % 30 + 1
    yy = yy < 1 and yy - 1 or yy
     return {yy, ym, yd}
     return {yy, ym, yd}
end
end
72行目: 73行目:
local function yogurianToGregorian(yYear, yMonth, yDay)
local function yogurianToGregorian(yYear, yMonth, yDay)
     checkYogurianValidDate(yYear, yMonth, yDay)
     checkYogurianValidDate(yYear, yMonth, yDay)
    yYear = yYear < 0 and yYear + 1 or yYear
     isLeapB = isLeap(yYear + 2020)
     isLeapB = isLeap(yYear + 2020)
     gDay = yMonth == 1 and yDay or (yMonth - 2) * 30 + (isLeapB and 36 or 35) + yDay
     gDay = yMonth == 1 and yDay or (yMonth - 2) * 30 + (isLeapB and 36 or 35) + yDay
97行目: 99行目:
return string.format(frame.args[4],gDate[1],gDate[2],gDate[3])
return string.format(frame.args[4],gDate[1],gDate[2],gDate[3])
end
end
p.isLeap = isLeap
p.leapdays = leapdays
p.checkValidDate = checkValidDate
p.checkYogurianValidDate = checkYogurianValidDate
p.ddCalculate = ddCalculate


p.gregorianToYogurianL = gregorianToYogurian
p.gregorianToYogurianL = gregorianToYogurian