Advertisement
killerbng

RU Info

Mar 5th, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.07 KB | None | 0 0
  1. import requests
  2. import json
  3. from datetime import datetime
  4. from pytz import timezone
  5. import pytz
  6.  
  7. def get_currency_convertion():
  8.     url = "http://www.freecurrencyconverterapi.com/api/v3/convert?q=USD_RUB&compact=y"
  9.     response = requests.get(url)
  10.     data = response.content
  11.     data = json.loads(data.decode())
  12.     print("$1 USD -> " + str(data["USD_RUB"]['val']) + " RUB")
  13.  
  14. def check_hour(n):
  15.     if n >= 24:
  16.         if n == 24:
  17.             n = "0"
  18.         else:
  19.             n = n - 24
  20.     else:
  21.         n = n
  22.     return n
  23.  
  24. def check_minute(n):
  25.     for i in range(0,10):
  26.         if i == n:
  27.             n = "0" + str(n)
  28.     return n
  29.  
  30. def get_time():
  31.     now = datetime.now()
  32.     fmt = '%Y-%m-%d %H:%M:%S'
  33.     eastern = timezone('US/Eastern')
  34.     moscow = timezone('Europe/Moscow')
  35.     loc_dt = eastern.localize(datetime(now.year, now.month, now.day, now.hour, now.minute, now.second))
  36.     moscow_dt = loc_dt.astimezone(moscow)
  37.     moscow_dt.strftime(fmt)
  38.     print("Date - Time")
  39.     print(moscow_dt)
  40.  
  41.  
  42. get_time()
  43. print("\n")
  44. get_currency_convertion()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement