#!/usr/bin/env python3 
########################################################################################## 
# Python date functions 
# Create a full year worth of dates
# You can even generate DB insert statements (ready for either Mysql or Oracle) insert
########################################################################################## 
print("Content-Type: text/html \n")     #http header with newline char (required for the web)
print('<pre>')                          #to produce better display on the web 

from datetime import datetime, timedelta
 
date = datetime(2025,1,1)                               #start date

holidays = ['2025-01-01','2025-01-20','2025-02-17','2025-04-20','2025-05-26','2025-07-04','2025-09-01','2025-11-27','2025-12-25']

for i in range(1,367):                                  #1-366
    yyyy_mm_dd  = date.strftime('%Y-%m-%d')             #Mysql date
    dd_Mon_yyyy = date.strftime('%d-%b-%Y')             #Oracle date
    yyyy        = date.year 
    mm          = date.month
    dd          = date.day
    hh          = date.hour
    mi          = date.minute
    ss          = date.second
    micro       = date.microsecond
    mthname     = date.strftime('%B')     
    dayname     = date.strftime('%A')
    daynum      = date.strftime('%w')
    julian      = date.strftime('%j')     
    weeknum     = date.strftime('%U')     
    if (int(daynum)> 0 and int(daynum)<=5): daytype  = 'weekday'
    if (int(daynum)==0 or  int(daynum)==6): daytype  = 'weekend'        
    if (yyyy_mm_dd in holidays):            daytype  = 'holiday'
    if (mm <= 3):                           quarter  = 1
    if (mm >= 4 and mm <= 6):               quarter  = 2
    if (mm >= 7 and mm <= 9):               quarter  = 3
    if (mm >= 10):                          quarter  = 4
    if (mm <= 5):                           semester = 'Spring'
    if (mm >= 6 and mm <= 8):               semester = 'Summer'
    if (mm >= 9):                           semester = 'Fall'                         
    if (mm == 12 or mm == 1  or mm == 2):   season   = 'Winter'
    if (mm == 3  or mm == 4  or mm == 5):   season   = 'Spring'
    if (mm == 6  or mm == 7  or mm == 8):   season   = 'Summer'
    if (mm == 9  or mm == 10 or mm == 11):  season   = 'Fall'

    print(yyyy_mm_dd, mthname, dayname, daytype, '  \t', '['+str(daynum)+']',  julian, weeknum, quarter,  hh, mi, ss, micro) 

#   print(F"insert into dates values({i},", end='')        #print DB insert statememts
#   print(F"'{yyyy_mm_dd}',", end='')                      #print Mysql date
#   print(F"'{dd_Mon_yyyy}',", end='')                     #print Oracle date
#   print(F"{yyyy},{mm},{dd},{julian},{weeknum},{quarter},'{mthname}','{dayname}','{daytype}','{semester}','{season}');")

    date += timedelta(days=1)                              #add 1 day to date