SUMMARY: Command or shell script to add times?.

From: Carl Christopher Bavington @ Langley (@)
Date: Thu May 22 2003 - 09:28:52 EDT


Thanks to Dr Tim Cutts.

I did it in ksh instead, adding 40 if gt than 59 etc, etc.
But Dr Tim suggested.

Fairly easy to do with an in-line perl script:

#!/bin/sh

addtime() {
  perl -e 'use integer;
    my ($h, $m, $s) = ($ARGV[0] =~ m/\G(\d\d)/g);
    if (($s += $ARGV[1]) >= 60) {
      $m += ($s/60); $s %= 60;
      if ($m >= 60) { $h += ($m/60); $m %= 60; }
      $h %= 24;
    }
    printf "%02d%02d%02d\n", $h,$m,$s;' $1 $2
}

addtime 235859 5

The contents of this email and any attachments are sent for the personal attention
of the addressee(s) only and may be confidential. If you are not the intended
addressee, any use, disclosure or copying of this email and any attachments is
unauthorised - please notify the sender by return and delete the message. Any
representations or commitments expressed in this email are subject to contract.
  
ntl Group Limited



This archive was generated by hypermail 2.1.7 : Sat Apr 12 2008 - 10:49:19 EDT