summaryrefslogtreecommitdiff
path: root/rt/lib/RT/Date.pm
diff options
context:
space:
mode:
Diffstat (limited to 'rt/lib/RT/Date.pm')
-rw-r--r--rt/lib/RT/Date.pm23
1 files changed, 14 insertions, 9 deletions
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<server> or C<UTC>
+
=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);
-
-
}