RosettaCodeData/Task/Date-manipulation/Lingo/date-manipulation-1.lingo
2023-07-01 13:44:08 -04:00

35 lines
989 B
Text

----------------------------------------
-- Returns string representation of given date object in YYYY-MM-DD hh:mm:ii format
-- @param {date} dateObj
-- @returns {string}
----------------------------------------
on dateToDateTimeString (dateObj)
str = ""
s = string(dateObj.year)
if s.length<4 then put "0000".char[1..4-s.length] before s
put s after str
s = string(dateObj.month)
if s.length<2 then s = "0"&s
put s after str
s = string(dateObj.day)
if s.length<2 then put "0" before s
put s after str
sec = dateObj.seconds
s = string(sec / 3600)
sec = sec mod 3600
if s.length<2 then put "0" before s
put s after str
s = string(sec / 60)
sec = sec mod 60
if s.length<2 then put "0" before s
put s after str
s = string(sec)
if s.length<2 then put "0" before s
put s after str
put ":" after char 12 of str
put ":" after char 10 of str
put " " after char 8 of str
put "-" after char 6 of str
put "-" after char 4 of str
return str
end