Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mojotx/date-manipulator
Simple application for generating RFC3339 timestamps, written in Go. Suitable for use in scripting, e.g., aws cloudwatch commands.
https://github.com/mojotx/date-manipulator
go golang timestamps
Last synced: about 2 months ago
JSON representation
Simple application for generating RFC3339 timestamps, written in Go. Suitable for use in scripting, e.g., aws cloudwatch commands.
- Host: GitHub
- URL: https://github.com/mojotx/date-manipulator
- Owner: mojotx
- License: mit
- Created: 2021-06-02T21:10:49.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-03T17:30:33.000Z (over 2 years ago)
- Last Synced: 2024-08-03T23:30:42.965Z (5 months ago)
- Topics: go, golang, timestamps
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.txt
Awesome Lists containing this project
- awesome-golang-repositories - date-manipulator
README
# Date Manipulator
Simple application for generating
[RFC3339 timestamps](https://datatracker.ietf.org/doc/html/rfc3339), written in
[Go](https://golang.org/).Install the program like this:
```shell
go install github.com/mojotx/date-manipulator@latest
```To get the current UTC timestamp in RFC3339 format, just run the binary:
```shell
$ date-manipulator
2021-06-02T20:56:32Z
```To get the UTC timestamp of 15 minutes ago, specify a valid Go
[time.Duration](https://golang.org/pkg/time/#ParseDuration) string,
like this:
```shell
$ date-manipulator -15m
2021-06-02T20:43:38Z
```To see 15 minutes ago, as well as current time, assuming
[Bash](https://www.gnu.org/software/bash/) as your shell:
```shell
printf "Past %22s\n Now %22s\n" $(date-manipulator -15m) $(date-manipulator)
Past 2021-06-02T20:47:19Z
Now 2021-06-02T21:02:19Z
```Note that there are multiple
[time.Duration](https://golang.org/pkg/time/#ParseDuration) units
suffixes, including "ns", "us" (or "µs"), "ms", "s", "m", and "h".
```shell
$ date-manipulator ; date-manipulator 12h
2021-06-02T21:05:45Z
2021-06-03T09:05:45Z
```I wrote this for scripting cloud things, such as AWS CLI commands.
For instance, to see CPU utilization for the past 12 hours in JSON
format:
```shell
$ aws cloudwatch get-metric-statistics \
--namespace AWS/RDS \
--metric-name CPUUtilization \
--period 60 \
--statistics Maximum \
--dimensions Name=DBInstanceIdentifier,Value=some-database-cluster \
--start-time $( date-manipulator -12h ) \
--end-time $( date-manipulator )
```This is licensed under the [MIT license](https://opensource.org/licenses/MIT).
If you find it useful, great!