Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Time Module

Expand Messages
  • Sheldon Smith
    According to the strftime manpage, p The AM or PM indicator is output as a string specified for the current locale. r The time in AM/PM notation is
    Message 1 of 3 , Nov 1, 2000
    • 0 Attachment
      According to the "strftime" manpage,

      p The AM or PM indicator is output as a string specified for the
      current locale.
      r The time in AM/PM notation is output, according to British/US
      con-
      ventions (%I:%M:%S [AM|PM]).

      Try "%p" or "%r".

      > -----Original Message-----
      > From: Mike Graves [mailto:mikegraves@...]
      > Sent: Wednesday, November 01, 2000 1:15 AM
      > Subject: [PBML] Time Module
      >
      > I need to refine the sub routine below to show am and pm if possible.
      > Any ideas?
      >
      > sub get_time {
      > # --------------------------------------------------------
      > # Returns the time in the format "hh-mm-ss".
      > #
      > $min = "%M";
      > $esthour = "%l";
      > $secs = "%S";
      > $hour= $esthour;
      > use POSIX qw(strftime);
      > $time = strftime "$hour:$min:$secs CST", localtime;
      > }
    • Tom Barron
      How bout this? sub get_time { # -------------------------------------------------------- # Returns the time in the format hh-mm-ss [a|p]m . # ($S,$M,$H) =
      Message 2 of 3 , Nov 1, 2000
      • 0 Attachment
        How 'bout this?

        sub get_time {
        # --------------------------------------------------------
        # Returns the time in the format "hh-mm-ss [a|p]m".
        #
        ($S,$M,$H) = localtime;
        $ampm = ($H <= 12) ? "am" : "pm";
        $H = (($H-1) % 12) + 1;
        $rval = sprintf("%02d:%02d:%02d %s", $H, $M, $S, ($H <= 12) ? "am" :
        "pm");
        }

        Mike Graves wrote:
        >
        > I need to refine the sub routine below to show am and pm if possible.
        > Any ideas?
        > ...
      • Smith, Eric - WPAFB/YSXOI
        Slight change to Tom Barron s sub... (put $ampm and added CST in the sprintf line)... sub get_time { #
        Message 3 of 3 , Nov 1, 2000
        • 0 Attachment
          Slight change to Tom Barron's sub...

          (put $ampm and added "CST" in the sprintf line)...

          sub get_time {
          # --------------------------------------------------------
          # Returns the time in the format "hh-mm-ss [a|p]m".
          #
          ($S,$M,$H) = localtime;
          $ampm = ($H <= 12) ? "am" : "pm";
          $H = (($H-1) % 12) + 1;
          $rval = sprintf("%02d:%02d:%02d %s", $H, $M, $S, $ampm);
          }

          - Eric D. Smith
        Your message has been successfully submitted and would be delivered to recipients shortly.