Method: Date#===
- Defined in:
- date_core.c
#===(other) ⇒ true, false
Returns true if self and other represent the same date, false if not, nil if the two are not comparable.
Argument other may be:
-
Another Date object:
d = Date.new(2022, 7, 27) # => #<Date: 2022-07-27 ((2459788j,0s,0n),+0s,2299161j)> prev_date = d.prev_day # => #<Date: 2022-07-26 ((2459787j,0s,0n),+0s,2299161j)> next_date = d.next_day # => #<Date: 2022-07-28 ((2459789j,0s,0n),+0s,2299161j)> d === prev_date # => false d === d # => true d === next_date # => false -
A DateTime object:
d === DateTime.new(2022, 7, 26) # => false d === DateTime.new(2022, 7, 27) # => true d === DateTime.new(2022, 7, 28) # => false -
A numeric (compares
self.jdtoother):d === 2459788 # => true d === 2459787 # => false d === 2459786 # => false d === d.jd # => true -
An object not comparable:
d === Object.new # => nil
6896 6897 6898 6899 6900 6901 6902 6903 6904 6905 6906 6907 6908 6909 6910 6911 6912 6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 |
# File 'date_core.c', line 6896
static VALUE
d_lite_equal(VALUE self, VALUE other)
{
if (!k_date_p(other))
return equal_gen(self, other);
{
get_d2(self, other);
if (!(m_gregorian_p(adat) == m_gregorian_p(bdat)))
return equal_gen(self, other);
{
VALUE a_nth, b_nth;
int a_jd, b_jd;
m_canonicalize_jd(self, adat);
m_canonicalize_jd(other, bdat);
a_nth = m_nth(adat);
b_nth = m_nth(bdat);
a_jd = m_local_jd(adat);
b_jd = m_local_jd(bdat);
if (f_eqeq_p(a_nth, b_nth) &&
a_jd == b_jd)
return Qtrue;
return Qfalse;
}
}
}
|