Class: RemLint::CalendarDate

Inherits:
Struct
  • Object
show all
Includes:
Comparable
Defined in:
lib/remlint/date_literal.rb

Overview

A fully-specified date written out in a trigger.

Remind accepts the three components in any order -- 1 Jan 2027, Jan 1 2027 and 2027 Jan 1 are the same date to GetFullDate -- so this collects components rather than matching a shape.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#dayObject

Returns the value of attribute day

Returns:

  • (Object)

    the current value of day



11
12
13
# File 'lib/remlint/date_literal.rb', line 11

def day
  @day
end

#monthObject

Returns the value of attribute month

Returns:

  • (Object)

    the current value of month



11
12
13
# File 'lib/remlint/date_literal.rb', line 11

def month
  @month
end

#yearObject

Returns the value of attribute year

Returns:

  • (Object)

    the current value of year



11
12
13
# File 'lib/remlint/date_literal.rb', line 11

def year
  @year
end

Instance Method Details

#<=>(other) ⇒ Object



28
29
30
# File 'lib/remlint/date_literal.rb', line 28

def <=>(other)
  to_i <=> other.to_i
end

#to_iObject

Days from 1990-01-01, the same epoch Remind counts from (BASE in src/custom.h.in). Only ever compared against another one of these, so it needs to be monotonic rather than meaningful.



15
16
17
# File 'lib/remlint/date_literal.rb', line 15

def to_i
  (year * 10_000) + (month * 100) + day
end

#to_sObject



19
20
21
22
23
24
25
26
# File 'lib/remlint/date_literal.rb', line 19

def to_s
  format(
    "%04d-%02d-%02d",
    year,
    month,
    day,
  )
end