diff --git a/README.md b/README.md index 0936247..d487bb0 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,17 @@ # Date Extra Package + +# WARNING! + +I have discovered that I managed to copy concepts from NodaTimes Period concept to Duration and there Duration concept to Period I got it backwards. Which I am sure is not helping anyone with back ground in nodatime doing the right thing with elm-date-extra. + +* I am not sure if i should swap them in elm-date-extra so they match the NodaTime terms at the moment. + ### Introduction An Elm language package for working with dates and times. + See bottom of this document for important history notes. ### Code format diff --git a/elm-package.json b/elm-package.json index 60aae1c..9dade56 100644 --- a/elm-package.json +++ b/elm-package.json @@ -1,5 +1,5 @@ { - "version": "9.2.0", + "version": "9.2.1", "summary": "Date Extra library add/subtract/diff/format etc dates.", "repository": "https://github.com/rluiten/elm-date-extra.git", "license": "BSD3", diff --git a/src/Date/Extra/Duration.elm b/src/Date/Extra/Duration.elm index dfd4736..1fe1287 100644 --- a/src/Date/Extra/Duration.elm +++ b/src/Date/Extra/Duration.elm @@ -11,6 +11,10 @@ module Date.Extra.Duration {-| A Duration is a length of time that may vary with calendar date and time. It can be used to modify a date. +Represents a period of time expressed in human chronological terms +in terms of a calendar which may have varying components based upon +the dates involved in the math. + When modify dates using Durations (Day | Month | Week | Year) this module compensates for day light saving hour variations to minimise the scenarios that cause the Hour field in the result to be different to the input date. @@ -303,7 +307,10 @@ addYear yearCount date = {-| Return a Period representing date difference. date1 - date2. If you add the result of this function to date2 with addend of 1 -will return date1. +will not always return date1, this is because this module supports +human calendar concepts liek Day Light Saving, Months with varying +number of days dependent on the month and leap years. So the difference +between two dates is dependent on when those dates are. **Differences to Period.diff** diff --git a/src/Date/Extra/Period.elm b/src/Date/Extra/Period.elm index 6151582..5ac23d8 100644 --- a/src/Date/Extra/Period.elm +++ b/src/Date/Extra/Period.elm @@ -1,9 +1,9 @@ module Date.Extra.Period exposing - ( add - , DeltaRecord - , diff + ( DeltaRecord , Period(..) + , add + , diff , toTicks , zeroDelta ) @@ -11,6 +11,8 @@ module Date.Extra.Period {-| Period is a fixed length of time. It is an elapsed time concept, which does not include the concept of Years Months or Daylight saving variations. + - Represents a fixed (and calendar-independent) length of time. + Name of type concept copied from NodaTime. @docs add @@ -162,18 +164,18 @@ diff date1 date2 = absDayDiff = abs onlyDaysDiff in - ( negate (absDayDiff // 7) - , negate (absDayDiff % 7) - ) + ( negate (absDayDiff // 7) + , negate (absDayDiff % 7) + ) else ( onlyDaysDiff // 7 , onlyDaysDiff % 7 ) in - { week = weekDiff - , day = dayDiff - , hour = hourDiff - , minute = minuteDiff - , second = secondDiff - , millisecond = millisecondDiff - } + { week = weekDiff + , day = dayDiff + , hour = hourDiff + , minute = minuteDiff + , second = secondDiff + , millisecond = millisecondDiff + }