Skip to content

Commit

Permalink
refactor: rewrite just with linux date fn
Browse files Browse the repository at this point in the history
  • Loading branch information
boredland committed Oct 28, 2022
1 parent fc0c71c commit dbc808b
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 514 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node-version: [10]

steps:
- name: Checkout Git Source
uses: actions/checkout@v1

- name: test1
id: time1
uses: nanzm/get-time-action@v1.1
uses: ./

- name: test1-output
env:
Expand All @@ -28,9 +27,9 @@ jobs:
- name: test2
id: time2
uses: nanzm/get-time-action@v1.1
uses: ./
with:
timeZone: 8
timeZone: UTC+8
format: 'YYYY-MM-DD_HH:mm:ss'

- name: test2-output
Expand Down
3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
MIT License
# MIT License

Copyright (c) 2022 BoredLand
Copyright (c) 2019 JantHsueh

Permission is hereby granted, free of charge, to any person obtaining a copy
Expand Down
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Get the time in the specified time zone
```yaml
- name: Get Time
id: time
uses: nanzm/get-time-action@v1.1
uses: boredland/get-time-action@master
with:
timeZone: 8
timeZone: UTC+8
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Usage
env:
Expand All @@ -22,18 +22,15 @@ Get the time in the specified time zone

| Parameter | Required | Info |
| ---------- | -------- | ------------------------------------------------------------ |
| `timeZone` | `false` | time Zone Default: 0 |
| `format` | `false` | timestamp format string Default: '' |

| `timeZone` | `false` | time Zone Default: UTC |
| `format` | `false` | timestamp format string Default: |

## Outputs

| Parameter | Info |
| ---------- | ------------------------------------------------------------ |
| `time` | time in the specified time zone|



## License

[MIT](LICENSE)
27 changes: 21 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,36 @@
name: 'Get Timestamp Action'
description: 'Get the time in the specified time zone'
author: 'nanzm'
author: 'boredland'
branding:
icon: arrow-right-circle
color: gray-dark
inputs:
timeZone:
description: 'time zone'
description: 'linux time zone'
required: false
default: 0
default: 'UTC'
format:
description: 'timestamp format'
required: false
default: ''
default: 'YYYY-MM-DD HH:mm:ss'
outputs:
time:
description: 'current time'
value: ${{ steps.time.outputs.value }}
runs:
using: 'node12'
main: 'dist/index.js'
using: "composite"
steps:
- id: time
shell: bash
env:
TZ: ${{ inputs.timeZone }}
run: |
TEMPLATE="${{ inputs.format }}"
TEMPLATE=${TEMPLATE/YYYY/%Y}
TEMPLATE=${TEMPLATE/MM/%m}
TEMPLATE=${TEMPLATE/DD/%d}
TEMPLATE=${TEMPLATE/HH/%H}
TEMPLATE=${TEMPLATE/mm/%M}
TEMPLATE=${TEMPLATE/ss/%S}
DATE=$(date +"$TEMPLATE")
echo "value=$DATE" >> $GITHUB_OUTPUT
7 changes: 0 additions & 7 deletions demo.js

This file was deleted.

Loading

0 comments on commit dbc808b

Please sign in to comment.