Class: Time

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#to_dateObject

Returns a Date object which denotes self.



8692
8693
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704
8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
# File 'ext/date/date_core.c', line 8692

static VALUE
time_to_date(VALUE self)
{
    VALUE y, nth, ret;
    int ry, m, d;

    y = f_year(self);
    m = FIX2INT(f_mon(self));
    d = FIX2INT(f_mday(self));

    decode_year(y, -1, &nth, &ry);

    ret = d_simple_new_internal(cDate,
        nth, 0,
        GREGORIAN,
        ry, m, d,
        HAVE_CIVIL);
    {
  get_d1(ret);
  set_sg(dat, DEFAULT_SG);
    }
    return ret;
}

#to_datetimeObject

Returns a DateTime object which denotes self.



8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
8745
8746
8747
8748
8749
8750
8751
8752
8753
8754
8755
# File 'ext/date/date_core.c', line 8722

static VALUE
time_to_datetime(VALUE self)
{
    VALUE y, sf, nth, ret;
    int ry, m, d, h, min, s, of;

    y = f_year(self);
    m = FIX2INT(f_mon(self));
    d = FIX2INT(f_mday(self));

    h = FIX2INT(f_hour(self));
    min = FIX2INT(f_min(self));
    s = FIX2INT(f_sec(self));
    if (s == 60)
  s = 59;

    sf = sec_to_ns(f_subsec(self));
    of = FIX2INT(f_utc_offset(self));

    decode_year(y, -1, &nth, &ry);

    ret = d_complex_new_internal(cDateTime,
         nth, 0,
         0, sf,
         of, DEFAULT_SG,
         ry, m, d,
         h, min, s,
         HAVE_CIVIL | HAVE_TIME);
    {
  get_d1(ret);
  set_sg(dat, DEFAULT_SG);
    }
    return ret;
}

#to_timeTime

Returns self.

Returns:



8680
8681
8682
8683
8684
# File 'ext/date/date_core.c', line 8680

static VALUE
time_to_time(VALUE self)
{
    return self;
}