X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Flib%2FRT%2FDate.pm;h=f951df3a2740435512fe0d84da1d9004b491e43e;hp=620acc7590b8aa14784e34577d1898b4df3f1cdc;hb=9c68254528b6f2c7d8c1921b452fa56064783782;hpb=d4d0590bef31071e8809ec046717444b95b3f30a diff --git a/rt/lib/RT/Date.pm b/rt/lib/RT/Date.pm index 620acc759..f951df3a2 100644 --- a/rt/lib/RT/Date.pm +++ b/rt/lib/RT/Date.pm @@ -226,23 +226,28 @@ sub Set { # {{{ sub SetToMidnight -=head2 SetToMidnight +=head2 SetToMidnight [Timezone => 'utc'] -Sets the date to midnight (at the beginning of the day) GMT +Sets the date to midnight (at the beginning of the day). Returns the unixtime at midnight. +Arguments: + +=over 4 + +=item Timezone - Timezone context C or C + =cut sub SetToMidnight { my $self = shift; - - use Time::Local; - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = gmtime($self->Unix); - $self->Unix(timegm (0,0,0,$mday,$mon,$year,$wday,$yday)); - + my %args = ( Timezone => 'UTC', @_ ); + if ( lc $args{'Timezone'} eq 'server' ) { + $self->Unix( Time::Local::timelocal( 0,0,0,(localtime $self->Unix)[3..7] ) ); + } else { + $self->Unix( Time::Local::timegm( 0,0,0,(gmtime $self->Unix)[3..7] ) ); + } return ($self->Unix); - - }