Skip to content

Commit 6c56273

Browse files
committed
chore(package): Replace moment with parse-ms
1 parent 7498588 commit 6c56273

File tree

3 files changed

+25
-11
lines changed

3 files changed

+25
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"dependencies": {
3535
"bluebird": "^3.4.6",
3636
"indicadoresdeldia": "^0.0.3",
37-
"moment": "^2.16.0",
37+
"parse-ms": "^1.0.1",
3838
"simple-encryptor": "^1.1.0",
3939
"toggl-api": "^1.0.1"
4040
},

src/script.coffee

+19-9
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
# A Hubot script to close time entries for new payment
33
#
44
# Dependencies:
5-
# "bluebird": "^3.2.1",
6-
# "moment": "^2.11.2",
7-
# "request-promise": "^2.0.0",
8-
# "simple-encryptor": "^1.0.3",
9-
# "toggl-api": "0.0.4"
5+
# "bluebird": "^3.4.6"
6+
# "indicadoresdeldia": "^0.0.3"
7+
# "parse-ms": "^1.0.1"
8+
# "simple-encryptor": "^1.1.0"
9+
# "toggl-api": "^1.0.1"
1010
#
1111
# Configuration:
1212
# TOGGL_CHANNEL
@@ -19,7 +19,7 @@
1919
# Author:
2020
# lgaticaq
2121

22-
moment = require "moment"
22+
parseMs = require "parse-ms"
2323
TogglClient = require "toggl-api"
2424
Promise = require "bluebird"
2525
simpleEncryptor = require "simple-encryptor"
@@ -30,8 +30,16 @@ getClient = (token) ->
3030
Promise.promisifyAll Object.getPrototypeOf toggl
3131
toggl
3232

33+
pad = (n, width, z="0") ->
34+
n = n + ""
35+
if n.length >= width
36+
return n
37+
else
38+
return new Array(width - n.length + 1).join(z) + n
39+
3340
parseDuration = (duration) ->
34-
return moment.utc(duration * 1000).format("HH:mm:ss")
41+
ms = parseMs(duration * 1000)
42+
return "#{pad(ms.hours, 2)}:#{pad(ms.minutes, 2)}:#{pad(ms.seconds, 2)}"
3543

3644
processTimeEntries = (timeEntries, amount, price) ->
3745
new Promise (resolve, reject) ->
@@ -93,8 +101,10 @@ module.exports = (robot) ->
93101
res.send "Processing time entries..."
94102
tags = ["Pagado"]
95103
action = "add"
96-
end = moment().toISOString()
97-
start = moment().subtract(1, "years").toISOString()
104+
today = new Date()
105+
end = today.toISOString()
106+
today.setFullYear(today.getFullYear() - 1)
107+
start = today.toISOString()
98108
user = robot.brain.userForName res.message.user.name
99109
encryptor = simpleEncryptor secret
100110
message = ""

yarn.lock

+5-1
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ module-not-found-error@^1.0.0:
11001100
version "1.0.1"
11011101
resolved "https://registry.yarnpkg.com/module-not-found-error/-/module-not-found-error-1.0.1.tgz#cf8b4ff4f29640674d6cdd02b0e3bc523c2bbdc0"
11021102

1103-
moment, moment@^2.10.6:
1103+
moment@^2.10.6:
11041104
version "2.16.0"
11051105
resolved "https://registry.yarnpkg.com/moment/-/moment-2.16.0.tgz#f38f2c97c9889b0ee18fc6cc392e1e443ad2da8e"
11061106

@@ -1195,6 +1195,10 @@ [email protected]:
11951195
version "1.0.4"
11961196
resolved "https://registry.yarnpkg.com/optparse/-/optparse-1.0.4.tgz#c062579d2d05d243c221a304a71e0c979623ccf1"
11971197

1198+
parse-ms:
1199+
version "1.0.1"
1200+
resolved "https://registry.yarnpkg.com/parse-ms/-/parse-ms-1.0.1.tgz#56346d4749d78f23430ca0c713850aef91aa361d"
1201+
11981202
parseurl@~1.3.0, parseurl@~1.3.1:
11991203
version "1.3.1"
12001204
resolved "https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.1.tgz#c8ab8c9223ba34888aa64a297b28853bec18da56"

0 commit comments

Comments
 (0)