-
Notifications
You must be signed in to change notification settings - Fork 21
/
action.js
37 lines (32 loc) · 1.22 KB
/
action.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const core = require('@actions/core')
const moment = require('moment-timezone')
function action() {
try {
const utcOffset = core.getInput('utcOffset', {required: false})
const format = core.getInput('format', {required: false})
const timezone = core.getInput('timezone', {required: false})
let time = moment()
if (timezone)
time = time.tz(timezone)
else if (utcOffset)
time = time.utcOffset(utcOffset)
else
time = time.utcOffset('+00:00')
core.setOutput('time', time.toISOString())
core.setOutput('ISOTime', time.toISOString())
core.setOutput('readableTime', time.toString())
core.setOutput('formattedTime', time.format(format))
let [year, month, day, hour, minute, second, millisecond] = time.toArray()
month = Number(month) + 1
core.setOutput('year', year)
core.setOutput('month', month)
core.setOutput('day', day)
core.setOutput('hour', hour)
core.setOutput('minute', minute)
core.setOutput('second', second)
core.setOutput('millisecond', millisecond)
} catch (error) {
core.setFailed(error.message)
}
}
module.exports = action