Skip to content

Instantly share code, notes, and snippets.

@WebDragon
Created January 27, 2025 22:47
Show Gist options
  • Save WebDragon/238720f895a26f589ce17f54b8a6d4c8 to your computer and use it in GitHub Desktop.
Save WebDragon/238720f895a26f589ce17f54b8a6d4c8 to your computer and use it in GitHub Desktop.
Generate a list of table/booth seatings for copy-paste via macros into a ticketing system for valentines day week so as to ease the burden of data entry by pre-generating the repetitive bits along with the changing ones
#!/usr/bin/perl
# MakeBoothDates - Scott R. Godin for MAD House Graphics
# generate booth/table text for hand-copying laboriously into the somewhat archaically designed
# bentobox ticket information options
use warnings;
use strict;
use v5.16;
use Getopt::Long;
use Try::Catch;
my (@types, $day, $year, $dt, $dt_end) = ("Table for two", "Booth for two");
use DateTime;
use Lingua::EN::Numbers::Ordinate;
GetOptions(
"day|d=i" => \$day,
"year|y=i" => \$year,
)
or die("Error in command line arguments\n");
die("'$day' is not a day-of-month number\n")
unless $day =~ /^\d{1,2}$/ and (( $day >= 1 ) and ( $day <= 31 ));
try {
my $test = DateTime->new( year => $year);
}
catch {
die("'$year' is not a valid year.");
};
$dt = DateTime->new(
year => $year, month => 2, day => $day,
hour => 16, minute => 0,
time_zone => "local"
);
$dt_end = DateTime->new(
year => $year, month => 2, day => $day,
hour => 22, minute => 30,
time_zone => "local"
);
sub datestring {
my $datetime = shift;
my ($month, $ordinal_day, $year, $hour, $min, $meridian) =
(
$datetime->month_abbr,
ordinate( $datetime->day ),
$datetime->year,
$datetime->strftime("%I"),
$datetime->strftime("%M"),
$datetime->strftime("%P"),
);
return "$month $ordinal_day, $year $hour:$min$meridian";
}
while ( $dt <= $dt_end) {
print (datestring($dt) . " $_\n") for @types;
print "\n";
$dt->add( minutes => 30 );
}
@WebDragon
Copy link
Author

WebDragon commented Jan 27, 2025

works along the lines of

05:34 PM {999} scott-desktop: ~>$ ./makeboothdates.pl --year 2025 --day 14
Feb 14th, 2025 04:00pm Table for two
Feb 14th, 2025 04:00pm Booth for two

Feb 14th, 2025 04:30pm Table for two
Feb 14th, 2025 04:30pm Booth for two

Feb 14th, 2025 05:00pm Table for two
Feb 14th, 2025 05:00pm Booth for two

Feb 14th, 2025 05:30pm Table for two
Feb 14th, 2025 05:30pm Booth for two

which then can be used in a macro that copies the line, alt-tabs over to the input fields, pastes the line, tabs to the next field, enters the count of how many tickets are available for that seat, tabs to the next field, and enters the ticket price for the table (or booth, using a 2nd but equivalent macro on a different keystroke)

when you have dates from the 13th to the 22nd to enter individual seatings and prices from 4pm to 10:30pm, you do whatever you can to ease that data-entry burden, when you're stuck with a system you can't improve and still need to code your way around the tedium to stay awake long enough to finish the job. :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment