Skip to content

Commit e04babc

Browse files
hugomrdiasvasco-santos
authored andcommitted
fix: remove leftpad (#22)
as leftpad was deprecated, this was modified
1 parent 643c010 commit e04babc

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"base32-encode": "^1.1.0",
3737
"debug": "^4.1.1",
3838
"interface-datastore": "~0.6.0",
39-
"left-pad": "^1.3.0",
4039
"libp2p-crypto": "~0.16.0",
4140
"multihashes": "~0.4.14",
4241
"peer-id": "~0.12.2",

src/utils.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
'use strict'
22

3-
const leftPad = require('left-pad')
4-
53
/**
64
* Convert a JavaScript date into an `RFC3339Nano` formatted
75
* string.
@@ -11,11 +9,11 @@ const leftPad = require('left-pad')
119
*/
1210
module.exports.toRFC3339 = (time) => {
1311
const year = time.getUTCFullYear()
14-
const month = leftPad(time.getUTCMonth() + 1, 2, '0')
15-
const day = leftPad(time.getUTCDate(), 2, '0')
16-
const hour = leftPad(time.getUTCHours(), 2, '0')
17-
const minute = leftPad(time.getUTCMinutes(), 2, '0')
18-
const seconds = leftPad(time.getUTCSeconds(), 2, '0')
12+
const month = String(time.getUTCMinutes() + 1).padStart(2, '0')
13+
const day = String(time.getUTCDate()).padStart(2, '0')
14+
const hour = String(time.getUTCHours()).padStart(2, '0')
15+
const minute = String(time.getUTCMinutes()).padStart(2, '0')
16+
const seconds = String(time.getUTCSeconds()).padStart(2, '0')
1917
const milliseconds = time.getUTCMilliseconds()
2018
const nanoseconds = milliseconds * 1000 * 1000
2119

0 commit comments

Comments
 (0)