Compare commits

...

2 Commits

Author SHA1 Message Date
8edc067a3b v0.0.394
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 1m31s
2024-02-21 18:40:42 +01:00
1007f2c834 v0.0.393
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m19s
2024-02-21 18:33:18 +01:00
2 changed files with 14 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.392" const GoextVersion = "0.0.394"
const GoextVersionTimestamp = "2024-02-21T18:32:06+0100" const GoextVersionTimestamp = "2024-02-21T18:40:42+0100"

View File

@@ -21,11 +21,11 @@ func (t Time) Serialize() string {
func (t Time) SerializeShort() string { func (t Time) SerializeShort() string {
if t.NanoSecond == 0 && t.Second == 0 { if t.NanoSecond == 0 && t.Second == 0 {
return fmt.Sprintf("%04d:%02d", t.Hour, t.Minute) return fmt.Sprintf("%02d:%02d", t.Hour, t.Minute)
} else if t.NanoSecond == 0 { } else if t.NanoSecond == 0 {
return fmt.Sprintf("%04d:%02d:%02d", t.Hour, t.Minute, t.Second) return fmt.Sprintf("%02d:%02d:%02d", t.Hour, t.Minute, t.Second)
} else { } else {
return fmt.Sprintf("%04d:%02d:%02d.%09d", t.Hour, t.Minute, t.Second, t.NanoSecond) return fmt.Sprintf("%02d:%02d:%02d.%09d", t.Hour, t.Minute, t.Second, t.NanoSecond)
} }
} }
@@ -125,6 +125,15 @@ func NewTime(h int, m int, s int, ns int) Time {
} }
} }
func NewTimeFromTS(t time.Time) Time {
return Time{
Hour: t.Hour(),
Minute: t.Minute(),
Second: t.Second(),
NanoSecond: t.Nanosecond(),
}
}
func NowTime(loc *time.Location) Time { func NowTime(loc *time.Location) Time {
now := time.Now().In(loc) now := time.Now().In(loc)
return NewTime(now.Hour(), now.Minute(), now.Second(), now.Nanosecond()) return NewTime(now.Hour(), now.Minute(), now.Second(), now.Nanosecond())