Last active
December 21, 2015 09:09
-
-
Save ruskotron/6283300 to your computer and use it in GitHub Desktop.
So imagine you have an arbitrary time system in place, where you define time as a number of minutes from a particular date (beginning of your "epoch"), or days from that particular date. If you ever needed to convert such dates to a sensible format, commands such as these could be useful to you. Just add to your environment (e.g. ".bashrc") e.g.…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set base of 'my' epoch (here it's the start of the 21st century) | |
export MY_EPOCH=$(expr $(date --date="2000/01/01 00:00:00" +%s)) | |
# format date and time, as expressed in minutes from start of 'my' epoch | |
function strftime_my { | |
date --date="@$(expr $MY_EPOCH + \( $1 \* 60 \) )" | |
} | |
# format date, as expressed in days from start of 'my' epoch | |
function strfdate_my { | |
date --date="@$(expr $MY_EPOCH + \( $1 \* 60 \* 60 \* 24 \) )" +"%a, %b %d, %Y" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment