Summary

time_seg makes you get the time division very easily.

Quick Reference

Installation

gem install time_seg or add gem "time_seg" in your Gemfile.

Configuration

require 'time_seg'

Example

get specific time type

get hour

TimeSeg.to_hour("1991-10-10 10:35:22")
=> 1991-10-10 10:00:00 +0800

get year

TimeSeg.to_day("1991-10-10 10:35:22")
=> 1991-10-10 00:00:00 +0800

get month

TimeSeg.to_month("1991-10-10 10:35:22")
=> 1991-10-01 00:00:00 +0800

get year

TimeSeg.to_year("1991-10-10 10:35:22")
=> 1991-01-01 00:00:00 +0800