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

22923Re: Time string parsing

Expand Messages
  • acummingsus
    Mar 1, 2006
    • 0 Attachment
      On Tuesday 28 February 2006 10:49, Shawn Hirn wrote:
      > I am working with the Time::Interval CPAN module's getInterval
      feature and
      [ . . ]
      > What I want is a variable called $y that's just the total seconds that's
      > represented by $x.
      >
      > For example, if ...
      >
      > $x = 1 hours, 2 minutes, 30 seconds" I want
      > $y = 3750
      >
      > So, how can I get to $y from $x? I have been reading the Perl
      cookbook and

      http://search.cpan.org/~ahicox/Time-Interval-1.0.5/Interval.pod

      if you want to use the same module in order to get your desired $y result:

      $number_of_seconds = convertInterval(
      hours => 1,
      minutes => 2,
      seconds => 30,
      ConvertTo => "seconds"
      );

      # ------------------

      yes, at that above url, its doc says that convertinterval will do that.

      Now, whether or not scalar variable can be used instead of the explicit
      (example: the explicit 2 for minutes), I don't know. Also you will
      need to
      parse $x in order to get each of the 3 numbers.

      Maybe there's another way, easier. But if scalar variable can be
      used, as I
      mentioned, then it could be done in this way.

      --
      Alan.
    • Show all 5 messages in this topic