Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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.

Awesome Lists containing this project

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!