Sha256: dca5ea6dc378041175723d5bcefd1895e46489fedf4372db7980f5945939c743

Contents?: true

Size: 831 Bytes

Versions: 5

Compression:

Stored size: 831 Bytes

Contents

class LocalTime.CalendarDate
  @fromDate: (date) ->
    new this date.getFullYear(), date.getMonth() + 1, date.getDate()

  @today: ->
    @fromDate(new Date)

  constructor: (year, month, day) ->
    @date = new Date Date.UTC(year, month - 1)
    @date.setUTCDate(day)

    @year = @date.getUTCFullYear()
    @month = @date.getUTCMonth() + 1
    @day = @date.getUTCDate()
    @value = @date.getTime()

  equals: (calendarDate) ->
    calendarDate?.value is @value

  is: (calendarDate) ->
    @equals(calendarDate)

  isToday: ->
    @is(@constructor.today())

  occursOnSameYearAs: (date) ->
    @year is date?.year

  occursThisYear: ->
    @occursOnSameYearAs(@constructor.today())

  daysSince: (date) ->
    if date
      (@date - date.date) / (1000 * 60 * 60 * 24)

  daysPassed: ->
    @constructor.today().daysSince(this)

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
solidus_auction-0.0.6 lib/assets/javascripts/src/local-time/calendar_date.coffee
solidus_auction-0.0.5 lib/assets/javascripts/src/local-time/calendar_date.coffee
solidus_auction-0.0.4 lib/assets/javascripts/src/local-time/calendar_date.coffee
solidus_auction-0.0.3 lib/assets/javascripts/src/local-time/calendar_date.coffee
solidus_auction-0.0.1 lib/assets/javascripts/src/local-time/calendar_date.coffee