Consider this code:
use Time::Piece;
my $format="%I:%M %p";
my $from="9 am";
my $d_from = Time::Piece->strptime($from, $format);
print ($d_from);
This prints:
Thu Jan 1 09:00:00 1970
Let's assume I cannot change $format or $from . The format may or may not have d/m/y values -> how do I make sure the converted object uses current date/time values for the missing components?
My use-case is this: I am writing a rules engine where a user specifies an arbitrary date/time format and I need to match rules and execute if current date/time falls in that date/time. Since the user controls $format and $from I don't know if $format will contain a day/date.
It may just contain a time (example $from="9 am" means "9 am every day" if a date is not provided. When converting to a Time::Piece object I want to make sure missing fields are replaced with current date/time not start of epoch time.