i have start_at, decimal quantity , interval 1 of day | week | month | year.
start_at = time.parse('2016-01-01 00:00:00 utc') # leap year quantity = bigdecimal.new('1.998') # changed 2.998, should end on 2/29/16 sometime interval = 'month' # of day|week|month|year with whole numbers, i've used duration i.e. 1.month, , looked @ date#advance, though recognizes integer values.
it seem simple cannot find in standard libraries or in activesupport.
references:
question
how can establish end_at date decimal?
why? purpose?
proration second given amount and given interval.
expectations
i'm looking end_at second accurate possible respect advancing next interval(s) decimal quantity. given interval = 'month', fractional part, when pass start of month, means in month , using it's duration. example, january 2016 31 days, while february (leap) 29 days (only in leap year).
i'd best option use ruby's date methods advance time based on whole number of decimal, calculate how many seconds fraction of current interval.
so 1.998 months, advance time 1 month. find current month in , .998 of seconds in month (i.e. july, 31x24x60x60x.998) , advance time many seconds.
Comments
Post a Comment