יחידה:תאריך עברי: הבדלים בין גרסאות בדף
אין תקציר עריכה |
אין תקציר עריכה |
||
| שורה 33: | שורה 33: | ||
end | end | ||
function mindate(fix | function mindate(fix) | ||
local monthtable = { | local monthtable = { | ||
["בתשרי"] = 7, ["בחשוון"] = 8, ["בכסלו"] = 9, ["בטבת"] = 10, | ["בתשרי"] = 7, ["בחשוון"] = 8, ["בכסלו"] = 9, ["בטבת"] = 10, | ||
| שורה 41: | שורה 41: | ||
} | } | ||
local indenttable = {176, 206, 235, 265, 294, 324, 0, 30, 59, 88, 117, 147, 147} | local indenttable = {176, 206, 235, 265, 294, 324, 0, 30, 59, 88, 117, 147, 147} | ||
return | return same("28-08-" .. frame:callParserFunction("padleft", {hebnum(sub1(fix[3], 3, len1(fix[3]))) + 1000 | ||
* hebnum(sub1((fix[3]), 1, 2)) - 3761, 4}) .. " + " .. (indenttable[monthtable[fix[2]]] | * hebnum(sub1((fix[3]), 1, 2)) - 3761, 4}) .. " + " .. (indenttable[monthtable[fix[2]]] | ||
+ hebnum(fix[1]) - 1) .. " days" | + hebnum(fix[1]) - 1) .. " days") | ||
end | end | ||
function exacttdate(hdate, mindate | function exacttdate(hdate, mindate) | ||
local count = 0 | local count = 0 | ||
local ans | local ans | ||
| שורה 52: | שורה 52: | ||
while (count < 82) do | while (count < 82) do | ||
ans = mindate .. " + " .. count .. " days" | ans = mindate .. " + " .. count .. " days" | ||
if (from(ans | if (from(ans) == hdate) then | ||
greg = same(ans | greg = same(ans) | ||
greg = same(greg .. " - ".. diff(greg) .. "days" | greg = same(greg .. " - ".. diff(greg) .. "days") | ||
checkcasp(greg) | checkcasp(greg) | ||
return | return to(greg) end | ||
count = count + 1 | count = count + 1 | ||
end | end | ||
aserror("Date not found") | |||
end | end | ||
function from(gdate | function from(gdate) | ||
return frame:callParserFunction("#זמןמ:xhxjj xjx xhxjY", gdate) | return frame:callParserFunction("#זמןמ:xhxjj xjx xhxjY", gdate) | ||
end | end | ||
function same(gdate | function same(gdate) | ||
return frame:callParserFunction("#זמןמ:d-m-Y", gdate) | return frame:callParserFunction("#זמןמ:d-m-Y", gdate) | ||
end | end | ||
function to(gdate | function to(gdate) | ||
return frame:callParserFunction("#זמןמ:j בF Y", gdate) | return frame:callParserFunction("#זמןמ:j בF Y", gdate) | ||
end | end | ||
| שורה 102: | שורה 98: | ||
end | end | ||
function takenumbers(wdate | function takenumbers(wdate) | ||
local s1 = find1(wdate, " ") | local s1 = find1(wdate, " ") | ||
local s2 = find1(wdate, " ", s1 + 1) | local s2 = find1(wdate, " ", s1 + 1) | ||
| שורה 154: | שורה 150: | ||
function checkcasp(wdate) | function checkcasp(wdate) | ||
local wnumbers = numtonums(wdate) | local wnumbers = numtonums(wdate) | ||
if wnumbers[3] < 360 or wnumbers[3] > 4357 | if wnumbers[3] < 360 or wnumbers[3] > 4357 or | ||
then | (wnumbers[3] == 1582 and wnumbers[2] == 10 and wnumbers[1] > 4 and wnumbers[1] < 15) | ||
then aserror("The date is not in the allowed casp") end | |||
end | end | ||
function fromhebrew1( | function fromhebrew1() | ||
local hdate = remove(frame.args[1]) | local hdate = remove(frame.args[1]) | ||
local fix = fixdate(hdate) | local fix = fixdate(hdate) | ||
return exacttdate(fix[4], mindate(fix | return exacttdate(fix[4], mindate(fix)) | ||
end | end | ||
function fromhebrew(frame | function fromhebrew(f) | ||
local success, res = pcall(fromhebrew1 | frame = f | ||
local success, res = pcall(fromhebrew1) | |||
if success | if success | ||
then return res | then return res | ||
| שורה 173: | שורה 171: | ||
end | end | ||
function tohebrew1( | function tohebrew1() | ||
local rem = remove(frame.args[1]) | local rem = remove(frame.args[1]) | ||
local take = takenumbers(rem | local take = takenumbers(rem) | ||
checkcasp(take) | checkcasp(take) | ||
return from(take | take = same(take .. " + " .. diff(take) .. " days") | ||
return from(take) | |||
end | end | ||
function tohebrew(frame | function tohebrew(f) | ||
frame = f | |||
local success, res = pcall(tohebrew1, frame) | local success, res = pcall(tohebrew1, frame) | ||
if success | if success | ||