#!/usr/bin/env perl # # make-dates # 2024-03-05 # # generate HCL files for all dates in a given year require 5.005 ; use strict ; use warnings ; use Getopt::Std ; use POSIX qw( strftime ) ; use Time::Local qw( timegm_posix ) ; ############################################################################### # # Return the number of days in a given YYYY-MM sub days_in_month($$) { my $yr = shift ; my $mo = shift ; my @dim = qw( 0 31 0 31 30 31 30 31 31 30 31 30 31 ) ; if ( $dim[$mo] > 0 ) { return $dim[$mo] ; } if ( $yr % 4 ) { return 28 ; } if ( $yr % 100 ) { return 29 ; } if ( $yr % 400 ) { return 28 ; } return 29 ; } ############################################################################### # # Generate files for a given month my @dow = qw( Sun Mon Tue Wed Thu Fri Sat ) ; sub gen_ym($$) { my $yr = shift ; my $mo = shift ; ######################################## # Build file headers my $title1 = strftime( '%B %Y' , 0 , 0 , 12 , 1 , $mo-1 , $yr-1900 ) ; my $title2 = strftime( '%b %Y' , 0 , 0 , 12 , 1 , $mo-1 , $yr-1900 ) ; my $text_a = <