<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=DueDateinBusinessHours</id>
	<title>DueDateinBusinessHours - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://rt-wiki.bestpractical.com/index.php?action=history&amp;feed=atom&amp;title=DueDateinBusinessHours"/>
	<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=DueDateinBusinessHours&amp;action=history"/>
	<updated>2026-08-22T15:38:25Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://rt-wiki.bestpractical.com/index.php?title=DueDateinBusinessHours&amp;diff=1030&amp;oldid=prev</id>
		<title>Admin: 3 revisions imported</title>
		<link rel="alternate" type="text/html" href="https://rt-wiki.bestpractical.com/index.php?title=DueDateinBusinessHours&amp;diff=1030&amp;oldid=prev"/>
		<updated>2016-04-06T20:08:52Z</updated>

		<summary type="html">&lt;p&gt;3 revisions imported&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Description: set ticket to be due in a specified number of business hours (so that weekends and nights are excluded)&lt;br /&gt;
&lt;br /&gt;
Uses Jesse Vincent&amp;#039;s Business::Hours library, available from CPAN&lt;br /&gt;
&lt;br /&gt;
 Condition: On Ticket Creation&lt;br /&gt;
 Template: Global template: Blank&lt;br /&gt;
 Action: User Defined&lt;br /&gt;
 &lt;br /&gt;
 Custom Action Preparation Code: return 1;&lt;br /&gt;
 Custom Action Cleanup Code:&lt;br /&gt;
 &lt;br /&gt;
 my $duedate = RT::Date-&amp;amp;gt;new($RT::SystemUser);&lt;br /&gt;
 my $hoursuntildue = 4;&lt;br /&gt;
 use Business::Hours;&lt;br /&gt;
 my $hours = Business::Hours-&amp;amp;gt;new();&lt;br /&gt;
 my $curtime = time;&lt;br /&gt;
 my $bus_hours_duetime = $hours-&amp;amp;gt;add_seconds ($curtime, ($hoursuntildue*60*60));&lt;br /&gt;
 $duedate-&amp;amp;gt;Set(Format=&amp;amp;gt;&amp;#039;unix&amp;#039;, Value=&amp;amp;gt;$bus_hours_duetime);&lt;br /&gt;
 $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetDue($duedate-&amp;amp;gt;ISO);&lt;br /&gt;
 return(1);&lt;br /&gt;
&lt;br /&gt;
This takes care of the case in which [[TimeLeft]] is modified after ticket creation:&lt;br /&gt;
&lt;br /&gt;
 Description: Upon editing, convert TimeLeft into business days&lt;br /&gt;
 &lt;br /&gt;
 Condition: User Defined&lt;br /&gt;
 Action: User Defined&lt;br /&gt;
 Template: Global template: Blank&lt;br /&gt;
 Stage: TransactionCreate&lt;br /&gt;
 &lt;br /&gt;
 Custom Condition:&lt;br /&gt;
  if ($self-&amp;amp;gt;TransactionObj-&amp;amp;gt;Field eq &amp;#039;TimeLeft&amp;#039;) {&lt;br /&gt;
   return(1);&lt;br /&gt;
  } else {&lt;br /&gt;
   return(undef);&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
 Custom Action Preparation Code: return 1;&lt;br /&gt;
 &lt;br /&gt;
 Custom action cleanup code:&lt;br /&gt;
  my $duedate = RT::Date-&amp;amp;gt;new($RT::SystemUser);&lt;br /&gt;
  my $hoursperday = 9;&lt;br /&gt;
  my $hoursuntildue = $self-&amp;amp;gt;TransactionObj-&amp;amp;gt;NewValue()*$hoursperday;&lt;br /&gt;
  use Business::Hours;&lt;br /&gt;
  my $hours = Business::Hours-&amp;amp;gt;new();&lt;br /&gt;
  my $curtime = time;&lt;br /&gt;
  my $bus_hours_duetime = $hours-&amp;amp;gt;add_seconds ($curtime, ($hoursuntildue*60*60));&lt;br /&gt;
  $duedate-&amp;amp;gt;Set(Format=&amp;amp;gt;&amp;#039;unix&amp;#039;, Value=&amp;amp;gt;$bus_hours_duetime);&lt;br /&gt;
  $self-&amp;amp;gt;TicketObj-&amp;amp;gt;SetDue($duedate-&amp;amp;gt;ISO);&lt;br /&gt;
  return(1);&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>