Skip to content

Commit e3b6f0d

Browse files
Remove Intl time formatter (#430)
1 parent 549f1f4 commit e3b6f0d

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

index.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ class Serializer {
7474
}
7575
}
7676

77-
pad2Zeros (num) {
78-
const s = '00' + num
79-
return s[s.length - 2] + s[s.length - 1]
80-
}
81-
8277
asAny (i) {
8378
return JSON.stringify(i)
8479
}
@@ -148,10 +143,7 @@ class Serializer {
148143
asTime (date, skipQuotes) {
149144
const quotes = skipQuotes === true ? '' : '"'
150145
if (date instanceof Date) {
151-
const hour = new Intl.DateTimeFormat('en', { hour: 'numeric', hourCycle: 'h23' }).format(date)
152-
const minute = new Intl.DateTimeFormat('en', { minute: 'numeric' }).format(date)
153-
const second = new Intl.DateTimeFormat('en', { second: 'numeric' }).format(date)
154-
return quotes + this.pad2Zeros(hour) + ':' + this.pad2Zeros(minute) + ':' + this.pad2Zeros(second) + quotes
146+
return quotes + new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toISOString().slice(11, 19) + quotes
155147
} else if (date && typeof date.format === 'function') {
156148
return quotes + date.format('HH:mm:ss') + quotes
157149
} else {

0 commit comments

Comments
 (0)