[Ruby-informix-misc] Starting to implement INTERVAL datatype

Jonathan Leffler jonathan.leffler at gmail.com
Thu Mar 27 09:58:31 EDT 2008


Looking good.

On Thu, Mar 27, 2008 at 2:04 AM, Gerardo Santana Gómez Garrido <
gerardo.santana at gmail.com> wrote:

> Here's another iteration of the interface to create an Interval object.
>
>    year_to_month:
>
>    # Interval.year_to_month(years = 0, months = 0)         =>  interval
>    # Interval.year_to_month(:years => yy, :months => mm)   =>  interval
>     #
>    # Creates an Interval object in the year-to-month scope.
>    #
>     # Interval.year_to_month(5)                           =>  '5-00'
>    # Interval.year_to_month(0, 3)                        =>  '0-03'
>    # Interval.year_to_month(5, 3)                        =>  '5-03'
>    # Interval.year_to_month(:years => 5.5)               =>  '5-06'
>    # Interval.year_to_month(:months =>3)                 =>  '0-03'
>    # Interval.year_to_month(:years => 5.5, :months =>5)  =>  '5-11'
>
>
>    day_to_second:
>
>    # Interval.day_to_second(days = 0, hours = 0,
>    #                        minutes = 0, seconds = 0)          => interval
>    # Interval.day_to_second(:days => dd, :hours => hh,
>    #                        :minutes => mm, :seconds => ss)    => interval
>    #
>    # Creates an Interval object in the day-to-second scope.
>    #
>    # Interval.day_to_second(5, 3)                      # => '5 3:00:
> 00.00000'
>    # Interval.day_to_second(0, 2, 0, 30)               # => '0 2:00:
> 30.00000'
>    # Interval.day_to_second(:hours=>2.5)               # => '0 2:30:
> 00.00000'
>    # Interval.day_to_second(:seconds=> 10.16)          # => '0 0:00:
> 10.16000'
>    # Interval.day_to_second(:days=>1.5, :hours=>2)     # => '1 14:00:
> 0.00000'
>


I'm wicked...

Interval.day_to_second(:days => -1.5, :hours => 12)     # => '-1 00:00:
00.00000'?

Basically, intervals can be negative, and what happens with negatives, with
some fields negative and some not negative?

What about:

Interval.day_to_second(:days => 1.5, :hours => 12, :sign => '-')    # => '-2
00:00:00.00000'?

An explicit sign, in other words.

-- 
Jonathan Leffler <jonathan.leffler at gmail.com> #include <disclaimer.h>
Guardian of DBD::Informix - v2008.0229 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/ruby-informix-misc/attachments/20080327/7b1fb6b8/attachment.html 


More information about the Ruby-informix-misc mailing list