Create Component Library (#43)

* Move src under playlet-lib

* Update configuration

* Update script

* Update script

* Working version

* Vs code config WIP

* Package lock sync

* Lint fix

* Fix images

* Reuse config files

* Kind of a working setup

* Lock node version

* Rename scripts to tools

* Fix build scripts, lib url system

* Lint fix

* rale

* Fix args and web server

* Load fallbacks and build script cleanups

* Remove unused method

* no message

* no message

* Remove generic message field

* Lint fix

* no message

* Use loading indicator on main app

* Add playlet lib version to settings

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2023-01-29 16:50:28 -05:00
1 parent 90df81df4b
commit 9d8a3d1cea
156 files changed
+3341 -213

No files matched your search

+112
View File
@@ -0,0 +1,112 @@
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 GetFormattedTimeLeft(unixTimestamp as integer) as string
if unixTimestamp = invalid
return "N/A"
end if
currentTime = TimeUtils.Now().AsSeconds()
timeLeft = unixTimestamp - currentTime
if timeLeft <= 0
return "now"
end if
if timeLeft < 60
result = `${timeLeft} second`
if timeLeft > 1
result += "s"
end if
return result
end if
timeLeft = timeLeft / 60.0
if timeLeft < 60
timeLeft = Cint(timeLeft)
result = `${timeLeft} minute`
if timeLeft > 1
result += "s"
end if
return result
end if
timeLeft = timeLeft / 60.0
if timeLeft < 24
timeLeft = Cint(timeLeft)
result = `${timeLeft} hour`
if timeLeft > 1
result += "s"
end if
return result
else
timeLeft = timeLeft / 24.0
timeLeft = Cint(timeLeft)
result = `${timeLeft} day`
if timeLeft > 1
result += "s"
end if
return result
end if
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
function ParseTime(time as string) as integer
hours = 0
minutes = 0
seconds = 0
tokens = time.Tokenize(":")
if tokens.Count() = 3
hours = tokens[0].ToInt()
minutes = tokens[1].ToInt()
seconds = tokens[2].ToInt()
else if tokens.Count() = 2
minutes = tokens[0].ToInt()
seconds = tokens[1].ToInt()
end if
return hours * 3600 + minutes * 60 + seconds
end function
end namespace