-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwindowsTime.py
More file actions
executable file
·33 lines (23 loc) · 1.01 KB
/
windowsTime.py
File metadata and controls
executable file
·33 lines (23 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""
windowsTime.py
My computer's CMOS is busted so the time oftenly resetted. This program set it automatically by using UTC internet time. This program using "date" program on windows, "elevate" program on windows http://code.kliu.org/misc/elevate/, bs4 and requests module.
bashrc: alias windowsTime="cd /d/PROGRAMMING/git/python-script/ && source /d/PROGRAMMING/git/python-script/my_env/Scripts/activate && python windowsTime.py"
"""
from bs4 import BeautifulSoup
import requests
from os import system
timezone = 7
r = requests.get("http://just-the-time.appspot.com/")
data = r.text
hour = (int(data[11:13:]) + timezone) % 24
data = data[:11] + str(hour) + data[13:]
date = data.split(" ")[0]
time = data.split(" ")[1]
date = date.replace("-", "/")
day = date.split("/")[0]
month = date.split("/")[1]
year = date.split("/")[2]
date = year + "/" + month + "/" + day
print("\n\nNow the program will launch elevated CMD. Enter these command:")
print("date " + date + " && " +"time " + time + "\n\n")
system("elevate cmd")