Refactor project

This commit is contained in:
Brahim Hadriche committed 2022-11-18 13:04:20 -05:00
1 parent 9c1a2b987b
commit 2f2516eade
115 files changed
+12522

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import "pkg:/source/utils/Types.bs"
namespace TimeUtils
' Helper function convert seconds to mm:ss format
' getTime(138) returns 2:18
function GetFormattedTime(length as integer) as string
minutes = (length \ 60).ToStr()
seconds = length mod 60
if seconds < 10
seconds = "0" + seconds.ToStr()
else
seconds = seconds.ToStr()
end if
return minutes + ":" + seconds
end function
function Now() as object
this = m.now
if this = invalid
this = CreateObject("roDateTime")
m.now = this
end if
this.mark()
return this
end function
function RFC1123_Date(when as object) as string
wd = when.getWeekday().left(3)
dom = Stri(when.getDayOfMonth()).trim()
mon = Ucase(TimeUtils.MonthStr(when.getMonth()).left(3))
yr = Stri(when.getYear()).trim()
hr = Stri(when.getHours()).trim()
mn = Stri(when.getMinutes()).trim()
sc = Stri(when.getSeconds()).trim()
date = wd + ", " + dom + " " + mon + " " + yr + " " + hr + ":" + mn + ":" + sc + " GMT"
return date
end function
function MonthStr(mNum as integer) as string
ma = m.Num2Month
if ma = invalid
ma = ["jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"]
m.Num2Month = ma
end if
return validstr(ma[mNum - 1])
end function
end namespace