Hi there
I have been looking into the source code from github, /lib/RT/Date.pm
Is it also possible to extract the parameter ‘Date’ in 3 parts? (example, day, 16) (example, month, 2)
Is it also possible to extract the parameter ‘Time’ in hours? (example, hours, 14)
The reason for this, is to convert an RFC2822 format date to custom business hours.
I already created a local perl script which will do the conversion using parameters from the perl DateTime lib.
For example a couple of parameters im using for the conversion
my @workingDays = (1,2,3,4,5); # for example, mon,tues,wed,thur,friday
my @workingHours = (20,21,22); # 8pm, 9pm,10pm
my $CurrentHour = $DateTime->hour; # 11pm
I saw that the parameters which are being calculated for the RFC2822 format are local, not gobal. then parameters returned as a joined parameter
Local parameters from Date.pm
my $self = shift;
my %args = ( Date => 1,
Time => 1,
Timezone => '',
DayOfWeek => 1,
Seconds => 1,
@_,
);
# 0 1 2 3 4 5 6 7 8 9
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$ydaym,$isdst,$offset) =
$self->Localtime($args{'Timezone'});
my ($date, $time) = ('','');
$date .= "$DAYS_OF_WEEK[$wday], " if $args{'DayOfWeek'} && $args{'Date'};
$date .= sprintf("%02d %s %04d", $mday, $MONTHS[$mon], $year) if $args{'Date'};
if ( $args{'Time'} ) {
$time .= sprintf("%02d:%02d", $hour, $min);
$time .= sprintf(":%02d", $sec) if $args{'Seconds'};
$time .= sprintf " %s%02d%02d", $self->_SplitOffset( $offset );
}
Then returns the at the end of the method using
return join ' ', grep $_, ($date, $time);
I have been looking at the docs
https://docs.bestpractical.com/rt/5.0.1/RT/Date.html
I see you have the functions such as
- GetWeekday
- GetMonth
- AddDays
Would be cool to have AddHours, but a mathematical conversion can be done and still use AddDays for this
I then was looking at the RFC2822 Date Format in the docs
This returns
Supports arguments: Timezone, Date, Time, DayOfWeek and Seconds.