# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Get the current data and time. We leave the integer timestamp in # # $now, and the OSI date/time in $cymdhms. We also leave a shorter # # date/time string without the century and year in $mdhms. Our return # # value is $now, the Unix integer timestamp. # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # sub dt { local($ss,$mm,$hh,$DD,$MM,$CY) = gmtime($now = time); $CY += 1900; $MM += 1; $hms = sprintf('%02d%02d%02d',$hh,$mm,$ss); $cymd = sprintf('%02d%02d%02d',$CY,$MM,$DD); $mdhms = sprintf('%02d%02d$hms',$MM,$DD); $cymdhms = "$cymd$hms"; # $cymd_hms = "$cymd $hms"; return $now; } sub hms { # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # # Convert a second counter into hh:mm:ss format. We trim away any initial # # zeroes and commas # # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # local($i) = @_; local($v) = sprintf("%02d",$i % 60); $i /= 60; if ($i) { $v = sprintf("%02d",$i % 60) . ':' . $v; if ($i) { $i /= 60; $v = sprintf("%d",$i % 60) . ':' . $v; } } $v =~ s/^[0:]*//; # Delete extra initial zeroes return $v; } &dt(); # Call once to initialize globals to current time 1;