mirror of
https://github.com/duke-git/lancet.git
synced 2026-11-16 05:12:11 +08:00
fix(package): [datetime] accept empty timezone options (#384)
This commit is contained in:
1 parent
cb45ef2d36
commit
417cf68bd8
2 files changed
+32
-7
No files matched your search
@@ -0,0 +1,25 @@
|
||||
package datetime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestEmptyTimezoneOptions(t *testing.T) {
|
||||
empty := []string{}
|
||||
now := time.Now()
|
||||
if got := FormatTimeToStr(now, "yyyy-mm-dd", empty...); got != FormatTimeToStr(now, "yyyy-mm-dd") {
|
||||
t.Errorf("unexpected date: %s", got)
|
||||
}
|
||||
if _, err := FormatStrToTime("2026-01-02", "yyyy-mm-dd", empty...); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if NowDateOrTime("yyyy", empty...) == "" {
|
||||
t.Error("empty date")
|
||||
}
|
||||
for _, fn := range []func(...string) int64{Timestamp, TimestampMilli, TimestampMicro, TimestampNano} {
|
||||
if fn(empty...) == 0 {
|
||||
t.Error("empty timestamp")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user