diff --git a/CHANGELOG.md b/CHANGELOG.md index 20229aa7..0f93669a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +- Nothing worth mentioning yet. + ## [0.40.1] - 2025-06-07 ### Added diff --git a/playlet-lib/src/components/Clock/Clock.bs b/playlet-lib/src/components/Clock/Clock.bs index 885544a6..e95aa31d 100644 --- a/playlet-lib/src/components/Clock/Clock.bs +++ b/playlet-lib/src/components/Clock/Clock.bs @@ -44,19 +44,11 @@ function Update() end if if hours > 12 - hours = hours - 12 + hours -= 12 end if - hoursStr = hours.ToStr() - minutesStr = minutes.ToStr() - - if hours < 10 - hoursStr = "0" + hoursStr - end if - - if minutes < 10 - minutesStr = "0" + minutesStr - end if + hoursStr = hours.ToStr("%02d") + minutesStr = minutes.ToStr("%02d") m.top.text = hoursStr + ":" + minutesStr + " " + ampm end function diff --git a/playlet-lib/src/components/Logger/Logger.bs b/playlet-lib/src/components/Logger/Logger.bs index c174546c..43239fbb 100644 --- a/playlet-lib/src/components/Logger/Logger.bs +++ b/playlet-lib/src/components/Logger/Logger.bs @@ -143,27 +143,10 @@ function FormatTime(dateTime as object) as string dateTime.Mark() dateTime.ToLocalTime() - hours = dateTime.GetHours().ToStr() - if hours.Len() = 1 - hours = "0" + hours - end if - - minutes = dateTime.GetMinutes().ToStr() - if minutes.Len() = 1 - minutes = "0" + minutes - end if - - seconds = dateTime.GetSeconds().ToStr() - if seconds.Len() = 1 - seconds = "0" + seconds - end if - - milliseconds = dateTime.GetMilliseconds().ToStr() - if milliseconds.Len() = 1 - milliseconds = "00" + milliseconds - else if milliseconds.Len() = 2 - milliseconds = "0" + milliseconds - end if + hours = dateTime.GetHours().ToStr("%02d") + minutes = dateTime.GetMinutes().ToStr("%02d") + seconds = dateTime.GetSeconds().ToStr("%02d") + milliseconds = dateTime.GetMilliseconds().ToStr("%03d") return "[" + hours + ":" + minutes + ":" + seconds + "." + milliseconds + "]" end function diff --git a/playlet-lib/src/source/utils/TimeUtils.bs b/playlet-lib/src/source/utils/TimeUtils.bs index b665e7f0..15b4252c 100644 --- a/playlet-lib/src/source/utils/TimeUtils.bs +++ b/playlet-lib/src/source/utils/TimeUtils.bs @@ -13,14 +13,10 @@ namespace TimeUtils minutes = (length \ 60) mod 60 seconds = length mod 60 - if seconds < 10 - seconds = "0" + seconds.ToStr() - else - seconds = seconds.ToStr() - end if + seconds = seconds.ToStr("%02d") - if minutes < 10 and hours > 0 - minutes = "0" + minutes.ToStr() + if hours > 0 + minutes = minutes.ToStr("%02d") else minutes = minutes.ToStr() end if