ProductPromotion
Logo

Ruby

made by https://0x3d.site

GitHub - darkleaf/date_range_formatter: The simple tool to make work with date ranges in Ruby more enjoyable.
The simple tool to make work with date ranges in Ruby more enjoyable. - darkleaf/date_range_formatter
Visit Site

GitHub - darkleaf/date_range_formatter: The simple tool to make work with date ranges in Ruby more enjoyable.

GitHub - darkleaf/date_range_formatter: The simple tool to make work with date ranges in Ruby more enjoyable.

Date Range Formatter

Build Status Gem Version

This gem makes working with dates more pretty. It works well with Ruby application and most frameworks like Ruby on Rails.

Installation

Very simple. Just add this code to Gemfile:

gem 'date_range_formatter'

Usage

Imagine the situation when you need to show dates of some stuff at your website. For example:

1 - 9 May 2014
2 January 2015
15 July 2016 - 13 February 2017

After that you should call the module DateRangeFormatter with arguments wchich describes the range of dates and format to display. For example, we have date_beginning, date_ending and format by default:

DateRangeFormatter.format('2013-01-14', '2013-02-15')
#=> '14 January - 15 February 2013'

Also you can use format_range method and enumerable object:

DateRangeFormatter.format_range(['2013-02-20', '2013-01-14', '2013-01-15'])
#=> '14 January - 20 February 2013'

If you want to show dates by another format, you can call it:

date_beginning = Date.new(2013, 01, 14)
date_ending = Date.new(2014, 02, 15)
date_range_str = DateRangeFormatter.format(date_beginning, date_ending, 'short')

If you want to show hours, you can call it:

DateRangeFormatter.format('10:00 2013-01-14', '20:00 2013-01-14', :with_time)
#=> '14 January 2013, 10am - 08pm'

See predefined formats. Also you can override this formats or add your own.

That's all. Enjoy your profit!

Other

This idea was appeared by looking at the article. Thanks to @mbillard.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory