https://github.com/ream88/mongoid-time_range
Time range type for Mongoid.
https://github.com/ream88/mongoid-time_range
Last synced: 5 months ago
JSON representation
Time range type for Mongoid.
- Host: GitHub
- URL: https://github.com/ream88/mongoid-time_range
- Owner: ream88
- Created: 2013-01-01T21:55:30.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2014-02-17T20:51:41.000Z (over 12 years ago)
- Last Synced: 2025-10-07T23:43:01.391Z (8 months ago)
- Language: Ruby
- Homepage: mariouher.com/mongoid-time_range
- Size: 238 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# mongoid-time_range
`Mongoid::TimeRange` defines a time range type for your Mongoid apps, which is stored internally as a hash with `from` and `to` keys.
## Installation
In your Gemfile:
```ruby
gem 'mongoid-time_range'
```
## Usage
```ruby
class Document
include Mongoid::Document
field :range, type: Mongoid::TimeRange
end
```
```ruby
year2013 = Document.create(range: { from: Time.now.at_beginning_of_year, to: Time.now.end_of_year })
year2013.range # => { from: 2013-01-01 00:00:00 +0100, to: 2013-12-31 23:59:59 +0100 }
```
If you want to use `TimeRange` directly instead of `Mongoid::TimeRange`:
```ruby
class Document
include Mongoid::Document
field :range, type: TimeRange
end
```
… your Gemfile must include a additional require statement:
```ruby
gem 'mongoid-time_range', require: 'mongoid/time_range/global'
```
## Contributing
1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
## Copyright
(The MIT license)
Copyright (c) 2013-2014 Mario Uher
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.