Class: Time
| Relationships & Source Files | |
| Namespace Children | |
|
Classes:
| |
| Inherits: | Object |
| Defined in: | lib/time.rb |
Constant Summary
-
VERSION =
Internal use only
# File 'lib/time.rb', line 30"0.4.2"
Instance Method Summary
-
#httpdate
Returns a string which represents the time as RFC 1123 date of HTTP-date defined by RFC 2616:
-
#iso8601(fraction_digits = 0)
Alias for #xmlschema.
-
#rfc2822
(also: #rfc822)
Returns a string which represents the time as date-time defined by RFC 2822:
-
#rfc822
Alias for #rfc2822.
-
#xmlschema(fraction_digits = 0)
(also: #iso8601, #iso8601)
Returns a string which represents the time as a dateTime defined by XML Schema:
Instance Method Details
#httpdate
Returns a string which represents the time as RFC 1123 date of HTTP-date defined by RFC 2616:
day-of-week, DD month-name CCYY hh:mm:ss GMT
Note that the result is always UTC (GMT).
require 'time'
t = Time.now
t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT"
You must require 'time' to use this method.
# File 'lib/time.rb', line 698
def httpdate getutc.strftime('%a, %d %b %Y %T GMT') end
#iso8601(fraction_digits = 0)
Alias for #xmlschema.
# File 'lib/time.rb', line 733
alias iso8601 xmlschema unless method_defined?(:iso8601)
#rfc2822 Also known as: #rfc822
Returns a string which represents the time as date-time defined by RFC 2822:
day-of-week, DD month-name CCYY hh:mm:ss zone
where zone is [+-]hhmm.
If self is a UTC time, -0000 is used as zone.
require 'time'
t = Time.now
t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 -0400"
You must require 'time' to use this method.
# File 'lib/time.rb', line 678
def rfc2822 strftime('%a, %d %b %Y %T ') << (utc? ? '-0000' : strftime('%z')) end
#rfc822
Alias for #rfc2822.
# File 'lib/time.rb', line 681
alias rfc822 rfc2822
#xmlschema(fraction_digits = 0) Also known as: #iso8601, #iso8601
Returns a string which represents the time as a dateTime defined by XML Schema:
CCYY-MM-DDThh:mm:ssTZD
CCYY-MM-DDThh:mm:ss.sssTZD
where TZD is Z or [+-]hh:mm.
If self is a UTC time, Z is used as TZD. [+-]hh:mm is used otherwise.
fraction_digits specifies a number of digits to use for fractional
seconds. Its default value is 0.
require 'time'
t = Time.now
t.iso8601 # => "2011-10-05T22:26:12-04:00"
You must require 'time' to use this method.
# File 'lib/time.rb', line 724
def xmlschema(fraction_digits=0) fraction_digits = fraction_digits.to_i s = strftime("%FT%T") if fraction_digits > 0 s << strftime(".%#{fraction_digits}N") end s << (utc? ? 'Z' : strftime("%:z")) end