Advertisement
rfmonk

time_strptime.py

Jan 17th, 2014
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import time
  4.  
  5.  
  6. def show_struct(s):
  7.     print ' tm_year   :', s.tm_year
  8.     print ' tm_mon    :', s.tm_mon
  9.     print ' tm_mday   :', s.tm_mday
  10.     print ' tm_hour   :', s.tm_hour
  11.     print ' tm_min    :', s.tm_min
  12.     print ' tm_sec    :', s.tm_sec
  13.     print ' tm_wday   :', s.tm_wday
  14.     print ' tm_yday   :', s.tm_yday
  15.     print ' tm_isdst  :', s.tm_isdst
  16.  
  17. now = time.ctime()
  18. print 'Now:', now
  19.  
  20. parsed = time.strptime(now)
  21. print '\nParsed:'
  22. show_struct(parsed)
  23.  
  24. print '\nFormatted:', time.strftime("%a %b %d %H:%M:%S %Y", parsed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement