Advertisement
Guest User

Untitled

a guest
Oct 9th, 2015
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. # Python 2.7.6
  2. # timeZoneExplorer.py
  3.  
  4. from pytz import timezone, common_timezones # import all_timezones for more exhaustive list
  5. from datetime import datetime
  6. import os
  7.  
  8. my_path = "C://some_folder"
  9. log_path = os.path.join(my_path + "/" + "loc_log.txt")
  10.  
  11. fmt = "%Y-%m-%d %H-%M-%S %Z%z"
  12.  
  13. fixed_length = 32
  14.  
  15. with open(log_path, "w") as my_log:
  16. for zone in common_timezones:
  17. local_time = datetime.now(timezone(zone)).strftime(fmt)
  18. space = fixed_length - len(zone)
  19.  
  20. #my_log.write("{0} : {1}".format(zone, local_time))
  21. my_log.write("{0}{1}:{2}".format(zone, " "*space, local_time))
  22. #my_log.write(zone + " "* space + ":" + local_time)
  23. my_log.write("\n")
  24.  
  25. print ("Done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement