# UnixTime - Displays Unix timestamps as human-readable information # # Written by Tim Sharpe # # Revision List # Date Ver Description #================================================================== # 06/13/2001 0.10 Original coding. # # # # import time, sys # # Store program name and version for inclusion into the standard banner banner1='UnixTime, v0.10' banner2='Copyright (C) 2005, Tim Sharpe . ' print banner1 + ', ' + banner2 print 'This program comes with ABSOLUTELY NO WARRANTY and is covered by the' print 'GNU General Public License, version 2. See the "license.txt"' print 'file for details. This is free software, and you are welcome to ' print 'redistribute it under conditions of the GNU General Public License.' print # def usage(): print 'Usage: unixtime.py [timestamp]' print print 'Where: timestamp = Unix timestamp (only reads the integer part of' print ' timestamps with fractional seconds).' print sys.exit() # # # Was the Unix timestamp provided? if len(sys.argv)<2: print '\nERROR! Unix timestamp not found! Exiting...\n' usage() # Extract the timestamp. We only casre about the integer part, but are # parsing the input first as a float to avoid "int" errors. try: timestamp=int(float(sys.argv[1])) except ValueError: print 'ERROR! Non-Numeric value provided for Unix timestamp! Exiting...\n' usage() # Remarked out because taking the localtime of a number invokes the # system time zone and provides a shifted time #date_time=time.strftime("%m/%d/%Y %H:%M", time.localtime(timestamp)) date_time=time.strftime("%m/%d/%Y %H:%M", time.gmtime(timestamp)) print print "Unix time", sys.argv[1], "translates to", date_time print