Wrong due date output, related to "SetToMidnight"?

Hi,

I have a scrip that triggers a template in which the due date of the
ticket is displayed.
In the template, I output the due date as such:

This ticket is due in {$Ticket->Due}.

Now, this works properly unless the due date is exactly midnight (00:00:00).
I would expect to have the right due date in the ticket… but instead,
I get 04:00:00.

After looking through the doc, I see that this could be due to
SetToMidnight which uses GMT rather than the local server time.

Is there some way to fix this ? We’d like to have tickets that are due
on midnight as we have a 24/7 operation :slight_smile:

Thanks,

David

Hello David,

Plain ->Due returns datetime in UTC. You have to use ->DueObj and some
formatter described in RT::Date.On Thu, Aug 20, 2009 at 4:29 PM, Davidfooraide@gmail.com wrote:

Hi,

I have a scrip that triggers a template in which the due date of the
ticket is displayed.
In the template, I output the due date as such:

This ticket is due in {$Ticket->Due}.

Now, this works properly unless the due date is exactly midnight (00:00:00).
I would expect to have the right due date in the ticket… but instead,
I get 04:00:00.

After looking through the doc, I see that this could be due to
SetToMidnight which uses GMT rather than the local server time.

Is there some way to fix this ? We’d like to have tickets that are due
on midnight as we have a 24/7 operation :slight_smile:

Thanks,

David


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.

I’ve had the same issue setting due dates in a scrip, I’ve done the
following to somewhat accurately go back (usual DST issues apply). I
imagine there might be cleaner ways. $1 being an ISO format, I’m parsing
from the email. I hope that helps.

  my $duedate = RT::Date->new($RT::SystemUser);
  $duedate->Set(Format=>'ISO', Value=>"$1");

  my $localdate = 

$duedate->AddSeconds(((gmtime)[2]-(localtime)[2])6060);
# ^^ this will add the difference from gmtime.
$duedate->Set(Format=>‘unix’, Value=>$localdate);
$self->TicketObj->SetDue( $duedate->ISO );

David wrote:

Also wanted to note the would probably fail if ran near the end of the
day, you may want to specify a specific $time in gmtime($time),
localtime($time).

Curtis Bruneau wrote:

Heh, I didn’t get problem at first. In 3.8 we fixed this, there is
Timezone argument in the SetToMidnight function. By default it’s
“utc”, but “system” or “user” can be used.On Thu, Aug 20, 2009 at 8:28 PM, Curtis Bruneaucurtisb@vianet.ca wrote:

Also wanted to note the would probably fail if ran near the end of the
day, you may want to specify a specific $time in gmtime($time),
localtime($time).

Curtis Bruneau wrote:

I’ve had the same issue setting due dates in a scrip, I’ve done the
following to somewhat accurately go back (usual DST issues apply). I
imagine there might be cleaner ways. $1 being an ISO format, I’m parsing
from the email. I hope that helps.

  my $duedate = RT::Date->new($RT::SystemUser);
  $duedate->Set(Format=>'ISO', Value=>"$1");

  my $localdate =

$duedate->AddSeconds(((gmtime)[2]-(localtime)[2])6060);
# ^^ this will add the difference from gmtime.
$duedate->Set(Format=>‘unix’, Value=>$localdate);
$self->TicketObj->SetDue( $duedate->ISO );

David wrote:

Hi,

I have a scrip that triggers a template in which the due date of the
ticket is displayed.
In the template, I output the due date as such:

This ticket is due in {$Ticket->Due}.

Now, this works properly unless the due date is exactly midnight (00:00:00).
I would expect to have the right due date in the ticket… but instead,
I get 04:00:00.

After looking through the doc, I see that this could be due to
SetToMidnight which uses GMT rather than the local server time.

Is there some way to fix this ? We’d like to have tickets that are due
on midnight as we have a 24/7 operation :slight_smile:

Thanks,

David


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com


The rt-users Archives

Community help: http://wiki.bestpractical.com
Commercial support: sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com

Best regards, Ruslan.