Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2a0452d

Browse files
committed
Merge branch '335-change-time-format' into 'master'
fix(engine): use RFC3339 as a time format (#335) Closes #335 See merge request postgres-ai/database-lab!502
2 parents 21759a2 + d143715 commit 2a0452d

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

‎engine/.golangci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ linters:
8282
- megacheck
8383
- misspell
8484
- prealloc
85-
# - revive # temporarily disabled: https://gitlab.com/postgres-ai/database-lab/-/merge_requests/498
85+
- revive
8686
- structcheck
8787
- stylecheck
8888
- unconvert

‎engine/internal/cloning/storage_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ const (
1919
"id": "c5bfsk0hmvjd7kau71jg",
2020
"snapshot": {
2121
"id": "east5@snapshot_20211001112229",
22-
"createdAt": "2021-10-01 11:23:11+00:00",
23-
"dataStateAt": "2021-10-01 11:22:29+00:00"
22+
"createdAt": "2021-10-01T11:23:11+00:00",
23+
"dataStateAt": "2021-10-01T11:22:29+00:00"
2424
},
2525
"protected": false,
2626
"deleteAt": "",
27-
"createdAt": "2021-10-01 12:25:52+00:00",
27+
"createdAt": "2021-10-01T12:25:52+00:00",
2828
"status": {
2929
"code": "OK",
3030
"message": "Clone is ready to accept Postgres connections."

‎engine/pkg/models/local_time.go‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import (
1010
"time"
1111
)
1212

13-
const localTimeFormat = "2006年01月02日 15:04:05 -07:00"
14-
1513
// LocalTime defines a type of time with custom marshalling depends on locale.
1614
type LocalTime struct {
1715
time.Time
@@ -30,7 +28,7 @@ func (t *LocalTime) UnmarshalJSON(data []byte) error {
3028
return nil
3129
}
3230

33-
parsedTime, err := time.Parse(localTimeFormat, string(localTime))
31+
parsedTime, err := time.Parse(time.RFC3339, string(localTime))
3432
if err != nil {
3533
return err
3634
}
@@ -46,5 +44,5 @@ func (t *LocalTime) MarshalJSON() ([]byte, error) {
4644
return []byte(`""`), nil
4745
}
4846

49-
return []byte(fmt.Sprintf("%q", t.Local().Format(localTimeFormat))), nil
47+
return []byte(fmt.Sprintf("%q", t.Local().Format(time.RFC3339))), nil
5048
}

‎engine/pkg/models/local_time_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestLocalTimeMarshalling(t *testing.T) {
1818
}{
1919
{
2020
inputTime: time.Date(2006, 02, 1, 15, 04, 05, 0, time.UTC),
21-
marshalling: `"2006-02-01 15:04:05 +00:00"`,
21+
marshalling: `"2006-02-01T15:04:05Z"`,
2222
},
2323
{
2424
inputTime: time.Time{},
@@ -45,7 +45,7 @@ func TestLocalTimeUnMarshalling(t *testing.T) {
4545
expectedTime time.Time
4646
}{
4747
{
48-
unmarshalling: []byte(`"2006-02-01 15:04:05+00:00"`),
48+
unmarshalling: []byte(`"2006-02-01T15:04:05+00:00"`),
4949
expectedTime: time.Date(2006, 02, 1, 15, 04, 05, 0, time.Local),
5050
},
5151
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /