struct Cronus::Date

Overview

A really, really simple Gregorian Date

Included Modules

Defined in:

cronus/date.cr

Constant Summary

DAYS_OF_THE_MONTH = {Month::January => 31, Month::February => 28, Month::March => 31, Month::April => 30, Month::May => 31, Month::June => 30, Month::July => 31, Month::August => 31, Month::September => 30, Month::October => 31, Month::November => 30, Month::December => 31}

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(year : Int, month : Int, day : Int) #

Date.new(2011, 1, 16)


[View source]
def self.new(parser : JSON::PullParser) #

Provide Object.from_json support. See https://github.com/crystal-lang/crystal/blob/master/src/json/from_json.cr


[View source]

Class Method Detail

def self.from_json(pull : JSON::PullParser) #

[View source]
def self.leap_year?(year : Int) #

[View source]
def self.parse(s : String) #

Parses an ISO 8601 date string of the format: YYYY-MM-DD


[View source]

Instance Method Detail

def <=>(other : Date) #
Description copied from module Comparable(Cronus::Date)

The comparison operator. Returns 0 if the two objects are equal, a negative number if this object is considered less than other, a positive number if this object is considered greater than other, or nil if the two objects are not comparable.

Subclasses define this method to provide class-specific ordering.

The comparison operator is usually used to sort values:

# Sort in a descending way:
[3, 1, 2].sort { |x, y| y <=> x } # => [3, 2, 1]

# Sort in an ascending way:
[3, 1, 2].sort { |x, y| x <=> y } # => [1, 2, 3]

[View source]
def day : Int8 #

[View source]
def inspect(io : IO) #
Description copied from struct Struct

Appends this struct's name and instance variables names and values to the given IO.

struct Point
  def initialize(@x : Int32, @y : Int32)
  end
end

p1 = Point.new 1, 2
p1.to_s    # "Point(@x=1, @y=2)"
p1.inspect # "Point(@x=1, @y=2)"

[View source]
def iso8601 : String #

[View source]
def month : Cronus::Date::Month #

[View source]
def to_json(builder : JSON::Builder) #

[View source]
def to_s(io : IO) #
Description copied from struct Struct

Same as #inspect(io).


[View source]
def year : Int16 #

[View source]