Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/data/doku/payment_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func ParsePrivateKeyPEM(pemStr string) (*rsa.PrivateKey, error) {
}

func formatTimestamp(t time.Time) string {
return t.Format("2006-01-02T15:04:05.000Z07:00")
return t.Format("2006-01-02T15:04:05Z07:00")
}

func formatAmount(amount float32) string {
Expand Down
10 changes: 6 additions & 4 deletions apps/api/data/doku/payment_repo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ func TestParsePrivateKeyPEM_NotAKey(t *testing.T) {
assert.Error(t, err)
}

func TestFormatTimestamp_ParsesBackAsRFC3339Nano(t *testing.T) {
now := time.Date(2021, 1, 8, 9, 57, 39, 877000000, time.FixedZone("WIB", 7*60*60))
func TestFormatTimestamp_MatchesDokuFormat(t *testing.T) {
now := time.Date(2020, 12, 21, 14, 56, 11, 877000000, time.FixedZone("WIB", 7*60*60))

formatted := formatTimestamp(now)

parsed, err := time.Parse(time.RFC3339Nano, formatted)
assert.Equal(t, "2020-12-21T14:56:11+07:00", formatted)

parsed, err := time.Parse(time.RFC3339, formatted)
require.NoError(t, err)
assert.True(t, now.Equal(parsed))
assert.True(t, now.Truncate(time.Second).Equal(parsed))
}

func TestFormatAmount(t *testing.T) {
Expand Down
Loading