README.md in fugit-1.0.0 vs README.md in fugit-1.1.0
- old
+ new
@@ -4,10 +4,12 @@
[![Build Status](https://secure.travis-ci.org/floraison/fugit.svg)](http://travis-ci.org/floraison/fugit)
[![Gem Version](https://badge.fury.io/rb/fugit.svg)](http://badge.fury.io/rb/fugit)
Time tools for [flor](https://github.com/floraison/flor) and the floraison group.
+It uses [et-orbi](https://github.com/floraison/et-orbi) to represent time instances and [raabro](https://github.com/floraison/raabro) as a basis for its parsers.
+
Fugit will probably become the foundation for [rufus-scheduler](https://github.com/jmettraux/rufus-scheduler) 4.x
## Related projects
@@ -23,10 +25,26 @@
* [ice_cube](https://github.com/seejohnrun/ice_cube) - Ruby date recurrence library
* [ISO8601](https://github.com/arnau/ISO8601) - Ruby parser to work with ISO8601 dateTimes and durations
* ...
+## `Fugit.parse(s)`
+
+The simplest way to use fugit is via `Fugit.parse(s)`.
+
+```ruby
+require 'fugit'
+
+Fugit.parse('0 0 1 jan *').class # ==> ::Fugit::Cron
+Fugit.parse('12y12M').class # ==> ::Fugit::Duration
+
+Fugit.parse('2017-12-12').class # ==> ::EtOrbi::EoTime
+Fugit.parse('2017-12-12 UTC').class # ==> ::EtOrbi::EoTime
+
+Fugit.parse('every day at noon').class # ==> ::Fugit::Cron
+```
+
## `Fugit::Cron`
A class `Fugit::Cron` to parse cron strings and then `#next_time` and `#previous_time` to compute the next or the previous occurrence respectively.
There is also a `#brute_frequency` method which returns an array `[ shortest delta, longest delta, occurrence count ]` where delta is the time between two occurences.
@@ -104,9 +122,56 @@
# => "1Y2M1D4h"
p Fugit::Duration.to_iso_s('1y2M1d4h')
# => "P1Y2M1DT4H" ISO 8601 duration
p Fugit::Duration.to_long_s('1y2M1d4h')
# => "1 year, 2 months, 1 day, and 4 hours"
+```
+
+## `Fugit::At`
+
+Points in time are parsed and given back as EtOrbi::EoTime instances.
+
+```ruby
+Fugit::At.parse('2017-12-12').to_s
+ # ==> "2017-12-12 00:00:00 +0900" (at least here in Hiroshima)
+
+Fugit::At.parse('2017-12-12 12:00:00 America/New_York').to_s
+ # ==> "2017-12-12 12:00:00 -0500"
+```
+
+Directly with `Fugit.parse_at(s)` is OK too:
+```ruby
+Fugit.parse_at('2017-12-12 12:00:00 America/New_York').to_s
+ # ==> "2017-12-12 12:00:00 -0500"
+```
+
+Directly with `Fugit.parse(s)` is OK too:
+```ruby
+Fugit.parse('2017-12-12 12:00:00 America/New_York').to_s
+ # ==> "2017-12-12 12:00:00 -0500"
+```
+
+## `Fugit::Nat`
+
+Fugit understand some kind of "natural" language:
+
+For example, those "every" get turned into `Fugit::Cron` instances:
+```ruby
+Fugit::Nat.parse('every day at five') # ==> '0 5 * * *'
+Fugit::Nat.parse('every weekday at five') # ==> '0 5 * * 1,2,3,4,5'
+Fugit::Nat.parse('every day at 5 pm') # ==> '0 17 * * *'
+Fugit::Nat.parse('every tuesday at 5 pm') # ==> '0 17 * * 2'
+Fugit::Nat.parse('every wed at 5 pm') # ==> '0 17 * * 3'
+Fugit::Nat.parse('every day at 16:30') # ==> '30 16 * * *'
+Fugit::Nat.parse('every day at noon') # ==> '0 12 * * *'
+Fugit::Nat.parse('every day at midnight') # ==> '0 0 * * *'
+Fugit::Nat.parse('every tuesday and monday at 5pm') # ==> '0 17 * * 1,2'
+Fugit::Nat.parse('every wed or Monday at 5pm and 11') # ==> '0 11,17 * * 1,3'
+```
+
+Directly with `Fugit.parse(s)` is OK too:
+```ruby
+Fugit.parse('every day at five') # ==> Fugit::Cron instance '0 5 * * *'
```
## LICENSE