Add the following code to your project's shard.yml under:
to use in production
- OR -
development_dependencies to use in development
Extends the functionality of the core Time object by adding a date specific span object called DateSpan. Whereas Time::Span represents a passage of time specified by seconds, Time::DateSpan represents a passage of time represented by months, days and seconds. With this, a developer can represent a specific number of days, regardless of a Daylight Savings Time shift, or a number of a months, regardless of any leap days that may be in between.
This library also overrides some of the convenience methods to the Int object, to return DateSpan instead of Span objects for Int#days, Int#weeks, Int#months, and Int#years.
NOTE: This library is just a rough draft. This functionality is being added to the Crystal core library.
Add this to your application's
dependencies: time_ext: github: your-github-user/time_ext
Creating an DateSpan instance:
Time::DateSpan.new(5, 0, 0) #=> 5 years Time::DateSpan.new(0, 0, 3) #=> 3 days
Integer convenience methods:
72.hours #=> 3.00:00:00 Time::Span 3.days #=> 3.00:00:00 Time::DateSpan
Adding Spans and DateSpans to a Time instance:
time = Time.new(2018, 11, 3, 9, 0, 0) time + 72.hours #=> 2018-11-06 08:00:00.0 -05:00 Local time + 3.days #=> 2018-11-06 09:00:00.0 -05:00 Local
TODO: Write development instructions here
git checkout -b my-new-feature)
git commit -am 'Add some feature')
git push origin my-new-feature)