An open API service indexing awesome lists of open source software.

https://github.com/readysteady/quarter

Ruby gem for working with standard calendar quarters
https://github.com/readysteady/quarter

date-time quarter ruby

Last synced: 2 months ago
JSON representation

Ruby gem for working with standard calendar quarters

Awesome Lists containing this project

README

        

# quarter

![Gem Version](https://badge.fury.io/rb/quarter.svg)
![Test Status](https://github.com/readysteady/quarter/actions/workflows/test.yml/badge.svg)

Ruby gem for working with standard calendar quarters.

## Install

Using Bundler:

$ bundle add quarter

Using RubyGems:

$ gem install quarter

## Usage

```ruby
require 'quarter'

date = Date.today

quarter = Quarter(date)

p quarter.start_date
p quarter.include?(date)
p quarter.next
p quarter.name
p quarter.to_s
p quarter.iso8601
```

### Quarter::Methods

Include the `Quarter::Methods` module for methods which can be used to get the quarter for a given year in a manner that resembles written english. For example:

include Quarter::Methods

q1 = Q1 2020

### Quarter::Constants

Include the `Quarter::Constants` module for constants which can be used to get the quarter for a given year in a manner that resembles written english. For example:

include Quarter::Constants

q1 = Q1/2020

q2 = 2020-Q2

### YAML integration

Require `quarter/yaml` for YAML integration which supports dumping and loading quarter objects to and from YAML as scalar values. For example:

require 'quarter/yaml'

puts YAML.dump([Quarter.now])