<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Time modifications in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535232#M678596</link>
    <description>Using my script and mixing in some bash scripting (just since it's easier) you should be able to do something like this:&lt;BR /&gt;&lt;BR /&gt;assuming the file starts each line like this:&lt;BR /&gt;20:00:00 text or logs or whatever&lt;BR /&gt;20:00:01 text or logs or whatever2&lt;BR /&gt;&lt;BR /&gt;# for i in $(cat time1); do date=$(echo $i | awk '{print $1}'); echo $i | replace "$date" "$(perl a.pl $date 30)" &amp;gt;&amp;gt; new_log.log; done&lt;BR /&gt;&lt;BR /&gt;This is just a quick and dirty thing, I wouldn't use this in production environments but as a one time use it might work :)&lt;BR /&gt;&lt;BR /&gt;It will produce a file name new_log.log which will contain the exact same entry's but with 30 seconds forward on all time stamps.&lt;BR /&gt;&lt;BR /&gt;should output something like this:&lt;BR /&gt;20:00:30 text or logs or whatever&lt;BR /&gt;20:00:31 text or logs or whatever2&lt;BR /&gt;&lt;BR /&gt;ps. it's untested :P ds.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
    <pubDate>Thu, 19 Nov 2009 14:20:50 GMT</pubDate>
    <dc:creator>Fredrik.eriksson</dc:creator>
    <dc:date>2009-11-19T14:20:50Z</dc:date>
    <item>
      <title>Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535224#M678588</link>
      <description>&lt;!--!*#--&gt;Hi All,&lt;BR /&gt;&lt;BR /&gt;Is there any inbuilt function in scripting to modify hh:mm:ss fields like adding/subtracting seconds or minutes etc?&lt;BR /&gt;&lt;BR /&gt;My file contains few lines starting with:&lt;BR /&gt;hh:mm:ss &lt;BR /&gt;&lt;BR /&gt;Thanks..</description>
      <pubDate>Tue, 17 Nov 2009 12:17:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535224#M678588</guid>
      <dc:creator>UniRock</dc:creator>
      <dc:date>2009-11-17T12:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535225#M678589</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Perl offers a wealth of ways and modules for adding and subtracting to dates and times.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 17 Nov 2009 13:16:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535225#M678589</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2009-11-17T13:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535226#M678590</link>
      <description>not really&lt;BR /&gt;I do&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;&lt;BR /&gt;function addseconds&lt;BR /&gt;{&lt;BR /&gt;typeset hms=$1&lt;BR /&gt;typeset -i delta=$2&lt;BR /&gt;res=$3&lt;BR /&gt;typeset -i H=${hms%%:*}&lt;BR /&gt;hms=${hms#*:}&lt;BR /&gt;typeset -i M=${hms%:*}&lt;BR /&gt;typeset -i S=${hms#*:}&lt;BR /&gt;typeset -i DM&lt;BR /&gt;typeset -i DH&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;S=S+delta&lt;BR /&gt;DM=S/60&lt;BR /&gt;&lt;BR /&gt;S=S-DM*60&lt;BR /&gt;if (( S &amp;lt; 0 ))&lt;BR /&gt;then&lt;BR /&gt;   S=S+60&lt;BR /&gt;   DM=DM-1&lt;BR /&gt;fi&lt;BR /&gt;M=M+DM&lt;BR /&gt;DH=M/60&lt;BR /&gt;M=M-DH*60&lt;BR /&gt;if (( M &amp;lt;0 ))&lt;BR /&gt;then&lt;BR /&gt;   M=M+60&lt;BR /&gt;   DH=DH-1&lt;BR /&gt;fi&lt;BR /&gt;&lt;BR /&gt;S=S+100&lt;BR /&gt;M=M+100&lt;BR /&gt;H=H+DH&lt;BR /&gt;&lt;BR /&gt;eval "$3=${H}:${M#1}:${S#1}"&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;addseconds   10:10:10   90 xx&lt;BR /&gt;echo $xx&lt;BR /&gt;addseconds   10:10:10   -90 xx&lt;BR /&gt;echo $xx&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 17 Nov 2009 13:50:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535226#M678590</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2009-11-17T13:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535227#M678591</link>
      <description>&lt;!--!*#--&gt;If you're just going to muck about with hh:mm:ss then something like this might do the trick:&lt;BR /&gt;&lt;BR /&gt;use Time::Local;&lt;BR /&gt;sub altertime {&lt;BR /&gt;   ($hh,$mm,$ss) = split(/:/, shift);&lt;BR /&gt;   ($ss,$mm,$hh) = localtime((($hh-1)*60)*60+$mm*60+$ss+shift);&lt;BR /&gt;   if($hh &amp;lt; 10){$hh = join('', "0", $hh);}&lt;BR /&gt;   if($mm &amp;lt; 10){$mm = join('', "0", $mm);}&lt;BR /&gt;   if($ss &amp;lt; 10){$ss = join('', "0", $ss);}&lt;BR /&gt;   $time = join(":", $hh,$mm,$ss);&lt;BR /&gt;   return $time;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$org_time = shift;&lt;BR /&gt;$time = altertime($org_time, shift);&lt;BR /&gt;printf("Original time: %s, Converted time: %s\n", $org_time, $time);&lt;BR /&gt;&lt;BR /&gt;The last part is just for proof of concept. The script takes 2 input parameters, the original time (ex. 23:59:44) and how many seconds back or forward (ex. -3600 will return 22:59:44 and 3600 will make it 00:59:59).&lt;BR /&gt;&lt;BR /&gt;# perl a.pl 23:59:59 -3600&lt;BR /&gt;Original time: 23:59:59, Converted time: 22:59:59&lt;BR /&gt;# perl a.pl 23:59:59 3600&lt;BR /&gt;Original time: 23:59:59, Converted time: 00:59:59&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2009 12:01:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535227#M678591</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2009-11-19T12:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535228#M678592</link>
      <description>&lt;!--!*#--&gt;For processing files I typically prefer perl or awk over shell scripting.&lt;BR /&gt;&lt;BR /&gt;And when using Perl for serious scripts using the localtime function to normalize to time in seconds since 1970 is typically best.&lt;BR /&gt;&lt;BR /&gt;For simple Perl scripts, converting to seconds since the begin of the day is often plenty good enough.&lt;BR /&gt;&lt;BR /&gt;Something like &lt;BR /&gt;&lt;BR /&gt;$last_time = $step = 0;&lt;BR /&gt;while (&amp;lt;&amp;gt;) {&lt;BR /&gt;  if (/^(\d\d):(\d\d):(\d\d)/) {&lt;BR /&gt;    $this_time = $1*3600 + $2*60 + $3;&lt;BR /&gt;    $seconds   = $this_time - $last_time;&lt;BR /&gt;    $seconds  += 86400 if $seconds &amp;lt; 0;&lt;BR /&gt;    $last_time = $this_time;&lt;BR /&gt;    $step++;&lt;BR /&gt;    print "step $step took $seconds seconds.\n";&lt;BR /&gt;  }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;That +86400 is there in case the file wraps around midnight.&lt;BR /&gt;&lt;BR /&gt;Cheers,&lt;BR /&gt;Hein&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2009 12:26:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535228#M678592</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-11-19T12:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535229#M678593</link>
      <description>a little better than my previous one:&lt;BR /&gt;#!/usr/bin/ksh&lt;BR /&gt;function addseconds&lt;BR /&gt;{&lt;BR /&gt;typeset hms=$1&lt;BR /&gt;typeset -i delta=$2&lt;BR /&gt;res=$3&lt;BR /&gt;typeset R=""&lt;BR /&gt;typeset -i S=${hms%%:*}&lt;BR /&gt;hms=${hms#*:}&lt;BR /&gt;S=S*60+${hms%%:*}&lt;BR /&gt;hms=${hms#*:}&lt;BR /&gt;S=S*60+${hms%%:*}+delta&lt;BR /&gt;if (( S &amp;lt; 0 ))&lt;BR /&gt;then&lt;BR /&gt;   R="-"&lt;BR /&gt;   S=-S&lt;BR /&gt;fi&lt;BR /&gt;typeset -i M=S/60&lt;BR /&gt;S=S-M*60+100&lt;BR /&gt;typeset -i H=M/60&lt;BR /&gt;M=M-H*60+100&lt;BR /&gt;if [ -z "$res" ]&lt;BR /&gt;then&lt;BR /&gt;echo "${R}${H}:${M#1}:${S#1}"&lt;BR /&gt;else&lt;BR /&gt;eval "$res=${R}${H}:${M#1}:${S#1}"&lt;BR /&gt;fi&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;addseconds 10:10:10 3600&lt;BR /&gt;addseconds 10:10:10 3600  x&lt;BR /&gt;echo $x&lt;BR /&gt;addseconds 10:10:10 -3600  x&lt;BR /&gt;echo $x&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2009 12:31:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535229#M678593</guid>
      <dc:creator>Laurent Menase</dc:creator>
      <dc:date>2009-11-19T12:31:28Z</dc:date>
    </item>
    <item>
      <title>Re: Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535230#M678594</link>
      <description>Hi All,&lt;BR /&gt;&lt;BR /&gt;Thanks a lot for your replies..&lt;BR /&gt;But how would I use these scripts with my file say time1.&lt;BR /&gt;&lt;BR /&gt;I have one file that has number of different entries containing hh:mm:ss. I need to advance these timings by say 30 seconds in every entry in this file (time1).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2009 12:35:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535230#M678594</guid>
      <dc:creator>UniRock</dc:creator>
      <dc:date>2009-11-19T12:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535231#M678595</link>
      <description>Hmmm, ok, We were all kinda assuming you had an existing file to process and find differences.&lt;BR /&gt;&lt;BR /&gt;To add times you you still should go to seconds, do the add as integers and convert back out.&lt;BR /&gt;Typically such conversion is just a divide by 24 to get HH, (or mod by 86400), a 'mod' function by 3600 to het MM and, a mod 60 to get the seconds.&lt;BR /&gt;You can of course also divide by 24 to get hours, subtract the whole hours and get minutes, divide by 60 to get minutes, subtract the whole minutes to get the seconds and toss into a formatted print.&lt;BR /&gt;&lt;BR /&gt;Using perl you can coerce gmtime to to this:&lt;BR /&gt;&lt;BR /&gt;$seconds = 123;&lt;BR /&gt;$hhmmss  = (split /\s+/, scalar gmtime( $ seconds ))[3]; &lt;BR /&gt;print $hhmmss"&lt;BR /&gt;&lt;BR /&gt;00:02:03&lt;BR /&gt;&lt;BR /&gt;Hint ... google for +hh:mm:ss +seconds&lt;BR /&gt;You;ll find plenty of perl/awk/shell alternatives.&lt;BR /&gt;&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Nov 2009 13:02:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535231#M678595</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2009-11-19T13:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: Time modifications</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535232#M678596</link>
      <description>Using my script and mixing in some bash scripting (just since it's easier) you should be able to do something like this:&lt;BR /&gt;&lt;BR /&gt;assuming the file starts each line like this:&lt;BR /&gt;20:00:00 text or logs or whatever&lt;BR /&gt;20:00:01 text or logs or whatever2&lt;BR /&gt;&lt;BR /&gt;# for i in $(cat time1); do date=$(echo $i | awk '{print $1}'); echo $i | replace "$date" "$(perl a.pl $date 30)" &amp;gt;&amp;gt; new_log.log; done&lt;BR /&gt;&lt;BR /&gt;This is just a quick and dirty thing, I wouldn't use this in production environments but as a one time use it might work :)&lt;BR /&gt;&lt;BR /&gt;It will produce a file name new_log.log which will contain the exact same entry's but with 30 seconds forward on all time stamps.&lt;BR /&gt;&lt;BR /&gt;should output something like this:&lt;BR /&gt;20:00:30 text or logs or whatever&lt;BR /&gt;20:00:31 text or logs or whatever2&lt;BR /&gt;&lt;BR /&gt;ps. it's untested :P ds.&lt;BR /&gt;&lt;BR /&gt;Best regards&lt;BR /&gt;Fredrik Eriksson</description>
      <pubDate>Thu, 19 Nov 2009 14:20:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/time-modifications/m-p/4535232#M678596</guid>
      <dc:creator>Fredrik.eriksson</dc:creator>
      <dc:date>2009-11-19T14:20:50Z</dc:date>
    </item>
  </channel>
</rss>

