Last active
April 3, 2018 15:46
-
-
Save pfuntner/ed3a7f9591c214e05ce320bf7a9df59d to your computer and use it in GitHub Desktop.
Unix-style date script for Cygwin/Git bash
This file contains hidden or 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
#! /usr/bin/python | |
import sys | |
import subprocess | |
cmd = sys.argv[1:] | |
if not any(word.startswith("+") for word in cmd): | |
cmd.insert(0, "+%a %b %e %H:%M:%S %Z %Y") | |
cmd.insert(0, "date") | |
exit(subprocess.Popen(cmd).wait()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Even the new changes are not perfect:
When a space separated the
-d
option and its argument, the script incorrectly assumed that+30 days
was a format specification. To solve this:date -ud +1\ day
is valid - add one day and report UTC information. The script would have to know this is means the same asdate -u -d +1\ day
How dumb is it for
date
to have the format specified this way?