Method: Time#utc
- Defined in:
- time.c
#utc ⇒ self Also known as: gm
Returns self, converted to the UTC timezone:
t = Time.new(2000) # => 2000-01-01 00:00:00 -0600
t.utc? # => false
t.utc # => 2000-01-01 06:00:00 UTC
t.utc? # => true
Related: Time#getutc (returns a new converted Time object).
4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 |
# File 'time.c', line 4179 static VALUE time_gmtime(VALUE time) { struct time_object *tobj; struct vtm vtm; GetTimeval(time, tobj); if (TZMODE_UTC_P(tobj)) { if (tobj->vtm.tm_got) return time; } else { time_modify(time); } vtm.zone = str_utc; GMTIMEW(tobj->timew, &vtm); time_set_vtm(time, tobj, vtm); tobj->vtm.tm_got = 1; TZMODE_SET_UTC(tobj); return time; } |