Comments (6)
OK, done.
from time.
Hmm, these should satisfy:
addGregorianDurationClip (diffGregorianDurationClip a b) b = a
addGregorianDurationRollOver (diffGregorianDurationRollOver a b) b = a
2000-01-30 + 13 months gives "2001-02-30", which is then clipped to 2001-02-28, or rolled over to 2001-03-02.
from time.
I think these results satisfy that? However, the -1
is surprising. This would also work:
2001-02-28 – 2000-01-30
clip: (13,0)
roll: (12,29)
2001-03-01 – 2000-01-30
clip: (13,1)
roll: (12,30)
2001-03-02 – 2000-01-30
clip: (13,2)
roll: (13,0)
2001-03-03 – 2000-01-30
clip: (13,3)
roll: (13,1)
2001-03-04 – 2000-01-30
clip: (13,4)
roll: (13,2)
Of course, now this means the number of months may be different.
from time.
Thanks for responding @AshleyYakeley!
What you've said has made sense to me.
Your example output eliminating the -1
feels a lot nicer to me; including in the sense that it looks like there aren't any "jumps": e.g consecutively, the clip currently goes (12,28)
to (12,29)
to (13,1)
(where is (13,0)
); instead it'd be (12,28)
to (13,0)
to (13,1)
.
Regarding the docs saying they'll be the same for positive durations; have I also misunderstood what a positive duration means here?
from time.
No, I think that's wrong and should be deleted.
from time.
Though it shouldn't necessarily have any bearing on what you decide to do, for comparison here's what the luxon JavaScript library produces:
2001-02-27 – 2000-01-30
{ years: 1, months: 0, days: 28 }
2001-02-28 – 2000-01-30
{ years: 1, months: 1, days: 0 }
2001-03-01 – 2000-01-30
{ years: 1, months: 1, days: 1 }
Using:
Interval.fromDateTimes(start, end)
.toDuration(
['years', 'months', 'days'],
{conversionAccuracy: 'longterm'}
).toObject()
from time.
Related Issues (20)
- CalendarDiffTime not normalised? HOT 6
- Expose functions needed to create `ParseTime` instances HOT 7
- read cannot parse show of ZonedTime HOT 5
- nominalDiffTimeToSeconds - strange result HOT 9
- [Controversial] Problems of `Read` instance of `TimeZone` HOT 5
- Read instance for strings w/o timezone has unclear fatal error message HOT 2
- Parsing padding widths with `parseTimeM` HOT 5
- Handling of days and weeks in CalendarDiffTime HOT 4
- Standard ISO8601 format for `LocalTime` is not padded HOT 4
- instance Enum DiffTime dangerous HOT 4
- Supporting decimal fractions on values other than seconds HOT 5
- reads :: ReadS Data.Time.LocalTime cannot parse show of ZonedTime HOT 3
- Data.Time.LocalTime.TimeZone is not a timezone but a timezone offset HOT 3
- Parsing of `Day` changed in time-1.11 HOT 1
- TH Lift instances for time types HOT 8
- Get WebAssembly build working HOT 1
- Please provide documentation for Data.Time.Format.ISO8601 HOT 5
- `systemToUTCTime` can produce invalid UTCTime HOT 3
- SecondOfDay and MinuteOfDay types HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from time.