Skip to content

Commit ca46007

Browse files
committed
use special dateformats
1 parent aa200cb commit ca46007

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

lib/constants.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
*/
88

99
module.exports = {
10+
DATE_FORMAT: 'extendedIsoDateTime',
11+
DATE_FORMAT_SIMPLE: 'extendedIsoTime',
12+
1013
/**
1114
* @type {K_ERROR_LIKE_KEYS}
1215
*/

lib/utils/format-time.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@
22

33
module.exports = formatTime
44

5+
const {
6+
DATE_FORMAT,
7+
DATE_FORMAT_SIMPLE
8+
} = require('../constants')
9+
510
const { dateformat, DateFormatter } = require('@pinojs/dateformat')
611
const createDate = require('./create-date')
712
const isValidDate = require('./is-valid-date')
813

9-
// 'HH:MM:ss.l'
10-
const simpleDateFormatter = new DateFormatter(function simple (date) {
11-
return `${this.HH(date)}:${this.MM(date)}:${this.ss(date)}.${this.l(date)}`
12-
})
13-
// 'yyyy-mm-dd HH:MM:ss.l o'
14-
const standardDateFormatter = new DateFormatter(function standard (date) {
15-
return `${this.yyyy(date)}-${this.mm(date)}-${this.dd(date)} ${this.HH(date)}:${this.MM(date)}:${this.ss(date)}.${this.l(date)} ${this.o(date)}`
16-
})
14+
const simpleDateFormatter = new DateFormatter(DATE_FORMAT_SIMPLE)
15+
const standardDateFormatter = new DateFormatter(DATE_FORMAT)
1716

1817
/**
1918
* Checks if the given format string is a UTC format.

0 commit comments

Comments
 (0)