ice_cube icon indicating copy to clipboard operation
ice_cube copied to clipboard

Add length options for duration

Open avit opened this issue 8 years ago • 3 comments

The RFC allows for specifying length of duration as periods of either:

  • Exact times (hours, minutes, seconds)
  • Nominal times (days, weeks, months)

The length of a day/week/month is changeable, and not supported by IceCube's implementation since it handles everything as an exact number of seconds internally.

Further to this, we may want to deprecate the end_time option in favour of duration, since it would be ambiguous with these options. (It also causes frequent confusion with until.)

avit avatar Sep 25 '17 19:09 avit

Agree with this - end_time always felt a bit weird to me. What do you think the interface should be here for duration being able to take nominal times?

seejohnrun avatar Sep 26 '17 14:09 seejohnrun

Well, let's look at the options:

"Numeric" values

schedule.duration = 3600    # SECONDS, unchanged
schedule.duration = 1.month # MONTH if recognizable via ActiveSupport

Hash value

(Seems most obvious)

schedule.duration = {days: 1, hours: 2}

Array

(Not sure if useful)

schedule.duration = [0, 0, 1, 2, 0, 0]  # Same as Time constructor (Y, M, D, H, M, S)

String value

(Maybe only useful for from_ical parsing?)

schedule.duration = "P15DT5H0M20S" # 15 DAY, 5 HOUR, 20 SEC

For reference: iCalendar RFC DURATION

avit avatar Sep 26 '17 18:09 avit

👍 to Hash syntax above

Also for 'string value' I think that maybe it should have to be wrapped in something like schedule.duration = IcalParser.parse_duration(dur)

seejohnrun avatar Sep 26 '17 19:09 seejohnrun