Skip to content

Commit 295789a

Browse files
committed
Add high-precision timestamp format
1 parent 45eeaf6 commit 295789a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

azblob/zc_sas_query_params.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func FormatTimesForSASSigning(startTime, expiryTime, snapshotTime time.Time) (st
4141

4242
// SASTimeFormat represents the format of a SAS start or expiry time. Use it when formatting/parsing a time.Time.
4343
const SASTimeFormat = "2006-01-02T15:04:05Z" //"2017-07-27T00:00:00Z" // ISO 8601
44-
var SASTimeFormats = []string{SASTimeFormat, "2006-01-02T15:04Z", "2006-01-02"} // ISO 8601 formats, please refer to https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas for more details.
44+
var SASTimeFormats = []string{"2006-01-02T15:04:05.0000000Z", SASTimeFormat, "2006-01-02T15:04Z", "2006-01-02"} // ISO 8601 formats, please refer to https://docs.microsoft.com/en-us/rest/api/storageservices/constructing-a-service-sas for more details.
4545

4646
// formatSASTimeWithDefaultFormat format time with ISO 8601 in "yyyy-MM-ddTHH:mm:ssZ".
4747
func formatSASTimeWithDefaultFormat(t *time.Time) string {

azblob/zt_url_blob_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,21 +1898,25 @@ func (s *aztestsSuite) TestBlobURLPartsSASQueryTimes(c *chk.C) {
18981898
"2020-04-20",
18991899
"2020-04-20T07:00Z",
19001900
"2020-04-20T07:15:00Z",
1901+
"2020-04-20T07:30:00.1234567Z",
19011902
}
19021903
StartTimesExpected := []time.Time{
19031904
time.Date(2020, time.April, 20, 0, 0, 0, 0, time.UTC),
19041905
time.Date(2020, time.April, 20, 7, 0, 0, 0, time.UTC),
19051906
time.Date(2020, time.April, 20, 7, 15, 0, 0, time.UTC),
1907+
time.Date(2020, time.April, 20, 7, 30, 0, 123456700, time.UTC),
19061908
}
19071909
ExpiryTimesInputs := []string{
19081910
"2020-04-21",
19091911
"2020-04-20T08:00Z",
19101912
"2020-04-20T08:15:00Z",
1913+
"2020-04-20T08:30:00.2345678Z",
19111914
}
19121915
ExpiryTimesExpected := []time.Time{
19131916
time.Date(2020, time.April, 21, 0, 0, 0, 0, time.UTC),
19141917
time.Date(2020, time.April, 20, 8, 0, 0, 0, time.UTC),
19151918
time.Date(2020, time.April, 20, 8, 15, 0, 0, time.UTC),
1919+
time.Date(2020, time.April, 20, 8, 30, 0, 234567800, time.UTC),
19161920
}
19171921

19181922
for i := 0; i < len(StartTimesInputs); i++ {

0 commit comments

Comments
 (0)