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

22925Re: [PBML] Re: Time string parsing

Expand Messages
  • Stan Horwitz
    Mar 1, 2006
    • 0 Attachment
      On Mar 1, 2006, at 4:13 AM — 3/1/06, acummingsus wrote:

      > 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.

      Thanks. For some reason, when I leave off the third argument, I get
      "HASH(0xa8220)"
      as a result. I also get the same thing if I use "0" as the third
      argument.

      Sorry, I should have indicated that information in my original posting.

      Does anyone see what I am doing wrong, or is this CPAN module buggy?
    • Show all 5 messages in this topic