date-manipulator

command module
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2022 License: MIT Imports: 3 Imported by: 0

README

Date Manipulator

Simple application for generating RFC3339 timestamps, written in Go.

Install the program like this:

go install github.com/mojotx/date-manipulator@latest

To get the current UTC timestamp in RFC3339 format, just run the binary:

$ date-manipulator
2021-06-02T20:56:32Z

To get the UTC timestamp of 15 minutes ago, specify a valid Go time.Duration string, like this:

$ date-manipulator -15m
2021-06-02T20:43:38Z

To see 15 minutes ago, as well as current time, assuming Bash as your 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 units suffixes, including "ns", "us" (or "µs"), "ms", "s", "m", and "h".

$ 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:

$ 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. If you find it useful, great!

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL