class Date

Constants

MAX_PRECISION

Public Class Methods

civil(y=nil, m=nil, d=nil, sg=Date::ITALY) click to toggle source
# File lib/date_time_precision/patch/1.8.7/date.rb, line 21
def civil(y=nil, m=nil, d=nil, sg=Date::ITALY)
  args = [y,m,d]
  precision = self.precision(args)

  args = normalize_new_args(args)

  unless jd = valid_civil?(*args)
    raise ArgumentError, 'invalid date'
  end

  date = new!(jd_to_ajd(jd, 0, 0), 0, sg)
  date.precision = precision
  date.attributes_set(y,m,d)
  date
end
Also aliased as: new, new, civil_orig
civil_orig(y=nil, m=nil, d=nil, sg=Date::ITALY)
Alias for: civil
new(y=nil, m=nil, d=nil, sg=Date::ITALY)
Also aliased as: new_orig
Alias for: civil
new_orig(y=nil, m=nil, d=nil, sg=Date::ITALY)
Alias for: new
parse(str='-4712-01-01T00:00:00+00:00', comp=false, sg=Date::ITALY) click to toggle source
# File lib/date_time_precision/patch/1.8.7/date.rb, line 5
def parse(str='-4712-01-01T00:00:00+00:00', comp=false, sg=Date::ITALY)
  elem = _parse(str, comp)
  precision = DateTimePrecision::precision(elem)
  d = new_by_frags(elem, sg)
  d.precision = precision
  d
end
Also aliased as: parse_orig
parse_orig(str='-4712-01-01T00:00:00+00:00', comp=false, sg=Date::ITALY)
Alias for: parse
strptime(str='-4712-01-01', fmt='%F', sg=Date::ITALY) click to toggle source
# File lib/date_time_precision/patch/1.8.7/date.rb, line 13
def strptime(str='-4712-01-01', fmt='%F', sg=Date::ITALY)
  elem = _strptime(str, fmt)
  precision = DateTimePrecision::precision(elem)
  d = new_by_frags(elem, sg)
  d.precision = precision
  d
end
Also aliased as: strptime_orig
strptime_orig(str='-4712-01-01', fmt='%F', sg=Date::ITALY)
Alias for: strptime
utc(*args) click to toggle source
# File lib/date_time_precision/patch/1.8.7/date.rb, line 39
def utc(*args)
  Time.utc(*args).to_date
end

Public Instance Methods

utc?() click to toggle source
# File lib/date_time_precision/lib.rb, line 14
def utc?
  offset == 0
end
utc_offset() click to toggle source
# File lib/date_time_precision/lib.rb, line 20
def utc_offset
  offset.numerator*3600
end