[ANN] Duration 0.0.4

Discussion in 'Ruby' started by Matthew Harris, Sep 28, 2006.

  1. Hi,

    I'd like to happily introduce Duration, the package for managing
    timespan durations. Have you ever been in a situation where you wanted
    to print a human-readable representation of a duration, maybe
    something like "4 days, 20 minutes and 8 seconds"?

    Well, Duration gives you this functionality. I have written a detailed
    wiki article at http://wiki.rubyonrails.org/rails/pages/Duration where
    you can read about how to install and use Duration.

    The current version is 0.0.4 and is quite stable. If you find any
    bugs, please email me the bug with a relevant email subject.

    Any feature requests should be sent to my email as well, as I am very
    interested in to hear and possibly implement what you as the user
    would feel would enhance Duration.

    Thanks.

    --
    Matt
     
    Matthew Harris, Sep 28, 2006
    #1
    1. Advertising

  2. On 9/29/06, Tanner Burson <> wrote:
    > On 9/28/06, Matthew Harris <> wrote:
    > >
    > > Hi,
    > >
    > > I'd like to happily introduce Duration, the package for managing
    > > timespan durations. Have you ever been in a situation where you wanted
    > > to print a human-readable representation of a duration, maybe
    > > something like "4 days, 20 minutes and 8 seconds"?
    > >
    > > Well, Duration gives you this functionality. I have written a detailed
    > > wiki article at http://wiki.rubyonrails.org/rails/pages/Duration where
    > > you can read about how to install and use Duration.
    > >
    > > The current version is 0.0.4 and is quite stable. If you find any
    > > bugs, please email me the bug with a relevant email subject.
    > >
    > > Any feature requests should be sent to my email as well, as I am very
    > > interested in to hear and possibly implement what you as the user
    > > would feel would enhance Duration.
    > >
    > > Thanks.
    > >
    > > --
    > > Matt

    >
    >
    > You mention that it can convert number of days/weeks into months. How do
    > you deal with the fact that a "month" doesn't have a standard number of
    > days? Do you do as the Rails extension does by assuming a fixed number, or
    > some other form of trickery?
    >
    >
    > --
    > ===Tanner Burson===
    >
    > http://tannerburson.com <---Might even work one day...
    >
    >


    Since durations are only based on timespans of fixed lengths, they do
    not work relatively. So there is no time-detection magic to determine
    the days in a given month, because also durations don't distinguish
    between what month it is (whether it be January or Feburary).
    BigDuration, the class that supports years and months will assume 30
    days as 1 month, and 12 months as 1 year.

    --
    Matt
     
    Matthew Harris, Sep 29, 2006
    #2
    1. Advertising

  3. On 06-09-29, at 08:59, Matthew Harris wrote:

    > On 9/29/06, Tanner Burson <> wrote:
    >> You mention that it can convert number of days/weeks into months.
    >> How do
    >> you deal with the fact that a "month" doesn't have a standard
    >> number of
    >> days? Do you do as the Rails extension does by assuming a fixed
    >> number, or
    >> some other form of trickery?

    >
    > Since durations are only based on timespans of fixed lengths, they do
    > not work relatively. So there is no time-detection magic to determine
    > the days in a given month, because also durations don't distinguish
    > between what month it is (whether it be January or Feburary).
    > BigDuration, the class that supports years and months will assume 30
    > days as 1 month, and 12 months as 1 year.


    Just to add a little bit here, in Io, our Duration module doesn't
    know anything about months at the moment, instead adding up days. It
    could keep a list holding the number of days in a month (in the case
    of february, if a leap year is detected, replace the second item in
    the list (28) with 29). Now that extension is pretty easy, but right
    now we only keep track of years, days, hours, and so on. You might
    consider doing something similar. It's fairly straight forward.

    Also, out of curiosity, why have two Duration classes? I can't see
    how BigDuration would be required, perhaps could you elaborate a little?

    > Matt


    --
    Jeremy Tregunna
     
    Jeremy Tregunna, Sep 29, 2006
    #3
  4. On 9/29/06, Jeremy Tregunna <> wrote:
    >
    > On 06-09-29, at 08:59, Matthew Harris wrote:
    >
    > > On 9/29/06, Tanner Burson <> wrote:
    > >> You mention that it can convert number of days/weeks into months.
    > >> How do
    > >> you deal with the fact that a "month" doesn't have a standard
    > >> number of
    > >> days? Do you do as the Rails extension does by assuming a fixed
    > >> number, or
    > >> some other form of trickery?

    > >
    > > Since durations are only based on timespans of fixed lengths, they do
    > > not work relatively. So there is no time-detection magic to determine
    > > the days in a given month, because also durations don't distinguish
    > > between what month it is (whether it be January or Feburary).
    > > BigDuration, the class that supports years and months will assume 30
    > > days as 1 month, and 12 months as 1 year.

    >
    > Just to add a little bit here, in Io, our Duration module doesn't
    > know anything about months at the moment, instead adding up days. It
    > could keep a list holding the number of days in a month (in the case
    > of february, if a leap year is detected, replace the second item in
    > the list (28) with 29). Now that extension is pretty easy, but right
    > now we only keep track of years, days, hours, and so on. You might
    > consider doing something similar. It's fairly straight forward.
    >
    > Also, out of curiosity, why have two Duration classes? I can't see
    > how BigDuration would be required, perhaps could you elaborate a little?
    >
    > > Matt

    >
    > --
    > Jeremy Tregunna
    >
    >
    >
    >
    >


    Duration and BigDuration are separate because BigDuration
    independantly deals with years and months. Duration, when given a year
    or a month will automatically change those to the number of weeks. I
    wanted to strictly limit Duration to consistent numbers (weeks, days,
    hours, minutes, seconds) and BigDuration to the inconsistent numbers
    (months).

    --
    Matt
     
    Matthew Harris, Sep 29, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Aaron

    duration

    Aaron, May 17, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    551
    Zuzar Lakdawala
    May 17, 2004
  2. Thomas

    User control cache duration

    Thomas, Jul 22, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    694
    Thomas
    Jul 23, 2004
  3. z. f.
    Replies:
    0
    Views:
    437
    z. f.
    Feb 10, 2005
  4. z. f.
    Replies:
    5
    Views:
    4,701
    Juan T. Llibre
    Feb 10, 2005
  5. Matthew Harris

    [ANN] Duration 0.1.0 released

    Matthew Harris, Dec 20, 2007, in forum: Ruby
    Replies:
    1
    Views:
    93
    Daniel Waite
    Dec 20, 2007
Loading...

Share This Page