-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatetime_iso_8601.py
executable file
·34 lines (24 loc) · 1018 Bytes
/
datetime_iso_8601.py
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
34
#!/usr/bin/python3
import pyautogui
import datetime
import subprocess
import time
import tkinter
from dateutil import tz
# The purpose of this script is to type out the current date and time according to the ISO-8601 standard.
# Preceding steps on an Ubuntu machine:
#sudo apt-get install idle3
#sudo apt-get install python3-pip
#sudo apt-get install scrot
#sudo apt-get install python-tk
#sudo apt-get install xsel xvkbd
# Couldn't get the platform-independent copy-paste handling to work. So calling Linux specific commands instead.
# Using primary clipboard, didn't manage to paste it though.
def copy_to_clipboard(text):
subprocess.run('echo -n "{}" | xsel --input'.format(text), shell=True)
def copy_type(text):
copy_to_clipboard(text)
time.sleep(0.3)
pyautogui.write(str(subprocess.run('xsel --output', shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8')), interval=0.01)
time.sleep (0.3)
copy_type(str(datetime.datetime.now(tz=tz.tzlocal()).replace(microsecond=0).isoformat()))