Date manipulation: Difference between revisions
Content added Content deleted
(Lingo added) |
(Change name of result.) |
||
Line 2,094: | Line 2,094: | ||
const func time: parseDate (in string: dateStri) is func |
const func time: parseDate (in string: dateStri) is func |
||
result |
result |
||
var time: |
var time: aTime is time.value; |
||
local |
local |
||
const array string: monthNames is [] ("January", "February", "March", "April", |
const array string: monthNames is [] ("January", "February", "March", "April", |
||
Line 2,103: | Line 2,103: | ||
begin |
begin |
||
dateParts := split(dateStri, ' '); |
dateParts := split(dateStri, ' '); |
||
aTime.year := integer parse (dateParts[3]); |
|||
aTime.month := 1; |
|||
while monthNames[ |
while monthNames[aTime.month] <> dateParts[1] do |
||
incr( |
incr(aTime.month); |
||
end while; |
end while; |
||
aTime.day := integer parse (dateParts[2]); |
|||
timeStri := dateParts[4]; |
timeStri := dateParts[4]; |
||
if endsWith(timeStri, "am") then |
if endsWith(timeStri, "am") then |
||
aTime.hour := integer parse (timeStri[.. pred(pos(timeStri, ':'))]); |
|||
elsif endsWith(timeStri, "pm") then |
elsif endsWith(timeStri, "pm") then |
||
aTime.hour := integer parse (timeStri[.. pred(pos(timeStri, ':'))]) + 12; |
|||
else |
else |
||
raise RANGE_ERROR; |
raise RANGE_ERROR; |
||
end if; |
end if; |
||
aTime.minute := integer parse (timeStri[succ(pos(timeStri, ':')) .. length(timeStri) - 2]); |
|||
if dateParts[5] <> "UTC" then |
if dateParts[5] <> "UTC" then |
||
aTime.timeZone := 60 * integer parse (dateParts[5][4 ..]); |
|||
end if; |
end if; |
||
end func; |
end func; |