Skip to content

Instantly share code, notes, and snippets.

@shomah4a
Last active September 13, 2016 05:34
Show Gist options
  • Save shomah4a/2ffd3a417239149d11b84feed5f4e2a0 to your computer and use it in GitHub Desktop.
Save shomah4a/2ffd3a417239149d11b84feed5f4e2a0 to your computer and use it in GitHub Desktop.
#-*- coding:utf-8 -*-
from __future__ import print_function
import sys
import datetime
def get_format():
if len(sys.argv) > 1:
return sys.argv[1]
return '%Y-%m-%dT%H:%M:%S'
def print_help():
if '-h' in sys.argv[1:] or '--help' in sys.argv[1:]:
print('''Usage
{0} [format]'''.format(sys.argv[0]))
sys.exit(0)
def main():
print_help()
fmt = get_format()
for line in sys.stdin:
t = datetime.datetime.now().strftime(fmt)
print('{0}\t{1}'.format(t, line), end='')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment