time-to-metrictime-converter/calender.py
2024-11-14 00:11:30 +00:00

55 lines
1.4 KiB
Python

from datetime import datetime
import sys
#Maths
day = datetime.now().timetuple().tm_yday # returns 1 for January 1st
year = datetime.now().year
year_hex = hex(year)[2:]
day_hex = hex(day)[2:]
if ((year % 4 == 0) and (year % 100 != 0)) or (year % 400 == 0):
leap_year = 1
else:
leap_year = 0
start_day = day
end_day = day + 32
if end_day > 366+leap_year:
end_day=366+leap_year
# Handle arguments
while (len(sys.argv) > 1):
if (sys.argv[1] == "--one"):
end_day = day + 32
if end_day > 366+leap_year:
end_day=366+leap_year
if sys.argv[1] == "--year":
start_day = 1
if sys.argv[1] == "--date-to-year":
end_day = 366+leap_year
# Printing
print(f" {year_hex}")
print("Prim Seco Tert Quat Quin Sena Sept Octo")
day_of_week_start = start_day % 8
for x in range(day_of_week_start-1):
print(" ", end="")
octal_counter = day_of_week_start -1
for x in range(start_day, end_day):
number = hex(x)[2:]
digits = len(number)
count = 4 - digits
for x in range(count):
print(" ", end="")
if (number == day_hex):
print("\033[101;1;5m", number, end="\033[0m")
else:
print(number, end=" ")
octal_counter+=1
if (octal_counter % 8 == 0):
print("")
print("\nPrim Seco Tert Quad Quin Sena Sept Octo")
print(f" {year_hex}")