Skip to content

Commit b12ec64

Browse files
committed
⬆️ dep: update gh checkout action to v5
1 parent 4a8b758 commit b12ec64

File tree

5 files changed

+22
-10
lines changed

5 files changed

+22
-10
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
steps:
4040
- name: Checkout repository
41-
uses: actions/checkout@v4
41+
uses: actions/checkout@v5
4242

4343
# Initializes the CodeQL tools for scanning.
4444
- name: Initialize CodeQL

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
steps:
2525
- name: Check out code
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@v5
2727

2828
- name: Setup Go Faster
2929
uses: WillAbides/setup-go-faster@v1.14.0

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
steps:
1515
- name: Checkout
16-
uses: actions/checkout@v4
16+
uses: actions/checkout@v5
1717
with:
1818
fetch-depth: 0
1919

timex/timex.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func FromString(s string, layouts ...string) (*Time, error) {
9292
return New(t), nil
9393
}
9494

95-
// LocalByName time for now
95+
// LocalByName time for now. eg: "Local", "UTC", "Asia/Shanghai"
9696
func LocalByName(tzName string) *Time {
9797
loc, err := time.LoadLocation(tzName)
9898
if err != nil {
@@ -274,21 +274,20 @@ func (t *Time) CustomHMS(hour, min, sec int) *Time {
274274
return FromTime(newTime)
275275
}
276276

277+
// IsEmpty check if time is empty. alias for t.IsZero
278+
func (t *Time) IsEmpty() bool { return t.IsZero() }
279+
277280
// IsBefore the given time
278281
func (t *Time) IsBefore(u time.Time) bool { return t.Before(u) }
279282

280283
// IsBeforeUnix the given unix timestamp
281-
func (t *Time) IsBeforeUnix(ux int64) bool {
282-
return t.Before(time.Unix(ux, 0))
283-
}
284+
func (t *Time) IsBeforeUnix(ux int64) bool { return t.Before(time.Unix(ux, 0)) }
284285

285286
// IsAfter the given time
286287
func (t *Time) IsAfter(u time.Time) bool { return t.After(u) }
287288

288289
// IsAfterUnix the given unix timestamp
289-
func (t *Time) IsAfterUnix(ux int64) bool {
290-
return t.After(time.Unix(ux, 0))
291-
}
290+
func (t *Time) IsAfterUnix(ux int64) bool { return t.After(time.Unix(ux, 0)) }
292291

293292
// Timestamp value. alias of t.Unix()
294293
func (t *Time) Timestamp() int64 { return t.Unix() }

timex/timex_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,28 @@ func TestWrap(t *testing.T) {
1414
tx := timex.Wrap(time.Now())
1515
assert.False(t, tx.IsZero())
1616

17+
// Wrap empty
18+
tx = timex.Wrap(time.Time{})
19+
assert.True(t, tx.IsZero())
20+
assert.True(t, tx.IsEmpty())
21+
22+
// FromTime
1723
tx = timex.FromTime(time.Now())
1824
assert.False(t, tx.IsZero())
1925

26+
// Local
2027
tx = timex.Local()
2128
assert.False(t, tx.IsZero())
2229
assert.False(t, tx.T().IsZero())
2330

31+
// FromUnix
2432
tx = timex.FromUnix(time.Now().Unix())
2533
assert.False(t, tx.IsZero())
34+
35+
// LocalByName
36+
tx = timex.LocalByName("Asia/Shanghai")
37+
assert.False(t, tx.IsEmpty())
38+
assert.Equal(t, "Asia/Shanghai", tx.T().Location().String())
2639
}
2740

2841
func TestFromDate(t *testing.T) {

0 commit comments

Comments
 (0)