Add `Dates.dateBasedDelta` and related methods.

No unit tests yet - maybe wait till we have them before merging.
We could also use a word like "jump" instead of "delta"

    Date.now().jump( Day, 7)

Good idea on using an enum. I could use the existing TimePeriod enum and an
Int argument... Or a new enum with constructors.

What's your preference?

It might negate the need for all those helper functions too.
On 19/12/2014 1:50 PM, "Franco Ponticelli" <notifications@github.com> wrote:

> In src/thx/core/Dates.hx
> <https://github.com/fponticelli/thx.core/pull/30#discussion-diff-22090742>
> :
>
> > @@ -80,6 +80,107 @@ Tells how many days in the month of the given date.
> >
> >    public static function snapTo(date : Date, period : TimePeriod) : Date
> >      return Date.fromTime(Timestamps.snapTo(date.getTime(), period));
> > +
> > +  /**
> > +      Perform a delta by creating a new Date object, rather than incrementing a timestamp.
> > +
> > +      This is important when the length of the delta is not a guaranteed number of seconds, for example:
> > +
> > +      - a month may have a differing number of days,
> > +      - a day may not be exactly 24 hours if Daylight Savings begins or ends during that day,
> > +      - a year may be 365 or or 366 days depending on the year.
> > +  **/
> > +  public static function dateBasedDelta(d : Date, ?yearDelta : Int = 0, ?monthDelta : Int = 0, ?dayDelta : Int = 0, ?hourDelta : Int = 0, ?minDelta : Int = 0, ?secDelta : Int = 0, ?msDelta : Int = 0 ) : Date {
>
> what about a simpler name like deltaPeriod? I would use just "delta" but
> it is already in DateTools.
>
> The arguments are quite easy to mix up ... maybe we could use an enum:
>
> enum TimeDelta {
>   Years(qt : Int);
>   Month(qt : Int);
>   ...
>   Sum(many : Iterable<TimeDelta>);
> }
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/fponticelli/thx.core/pull/30/files#r22090742>.
>