Linux heracles.o2switch.net 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
/
opt
/
alt
/
ruby21
/
share
/
ri
/
2.1.0
/
system
/
Time
/
//opt/alt/ruby21/share/ri/2.1.0/system/Time/cdesc-Time.ri
U:RDoc::NormalClass[iI" Time:ET@I"Object;To:RDoc::Markup::Document:@parts[ o;;[o:RDoc::Markup::Paragraph;[I"'Time serialization/deserialization;T: @fileI""ext/json/lib/json/add/time.rb;T:0@omit_headings_from_table_of_contents_below0o;;[ ; I"lib/rake/ext/time.rb;T;0o;;[ ; I"lib/rss/rss.rb;T;0o;;[+S:RDoc::Markup::Heading: leveli: textI"time.rb;To:RDoc::Markup::BlankLine o; ;[I"SWhen 'time' is required, Time is extended with additional methods for parsing ;TI"and converting Times.;T@S;; i;I" Features;T@o; ;[I"PThis library extends the Time class with the following conversions between ;TI"#date strings and Time objects:;T@o:RDoc::Markup::List: @type:BULLET:@items[ o:RDoc::Markup::ListItem:@label0;[o; ;[I"Idate-time defined by {RFC 2822}[http://www.ietf.org/rfc/rfc2822.txt];To;;0;[o; ;[I"IHTTP-date defined by {RFC 2616}[http://www.ietf.org/rfc/rfc2616.txt];To;;0;[o; ;[I"<dateTime defined by XML Schema Part 2: Datatypes ({ISO ;TI"88601}[http://www.iso.org/iso/date_and_time_format]);To;;0;[o; ;[I"+various formats handled by Date._parse;To;;0;[o; ;[I"-custom formats handled by Date._strptime;T@S;; i;I" Examples;T@o; ;[I"3All examples assume you have loaded Time with:;T@o:RDoc::Markup::Verbatim;[I"require 'time' ;T:@format0o; ;[I"KAll of these examples were done using the EST timezone which is GMT-5.;T@S;; i;I"Converting to a String;T@o;;[ I"t = Time.now ;TI"1t.iso8601 # => "2011-10-05T22:26:12-04:00" ;TI"7t.rfc2822 # => "Wed, 05 Oct 2011 22:26:12 -0400" ;TI"5t.httpdate # => "Thu, 06 Oct 2011 02:26:12 GMT" ;T;0S;; i;I"Time.parse;T@o; ;[I"M#parse takes a string representation of a Time and attempts to parse it ;TI"using a heuristic.;T@o;;[I"<Date.parse("2010-10-31") #=> 2010-10-31 00:00:00 -0500 ;T;0o; ;[I"KAny missing pieces of the date are inferred based on the current date.;T@o;;[I"1# assuming the current date is "2011-10-31" ;TI"7Time.parse("12:00") #=> 2011-10-31 12:00:00 -0500 ;T;0o; ;[I"SWe can change the date used to infer our missing elements by passing a second ;TI"Sobject that responds to #mon, #day and #year, such as Date, Time or DateTime. ;TI"$We can also use our own object.;T@o;;[I"class MyDate ;TI"% attr_reader :mon, :day, :year ;TI" ;TI"& def initialize(mon, day, year) ;TI", @mon, @day, @year = mon, day, year ;TI" end ;TI" end ;TI" ;TI"#d = Date.parse("2010-10-28") ;TI"#t = Time.parse("2010-10-29") ;TI"'dt = DateTime.parse("2010-10-30") ;TI"!md = MyDate.new(10,31,2010) ;TI" ;TI";Time.parse("12:00", d) #=> 2010-10-28 12:00:00 -0500 ;TI";Time.parse("12:00", t) #=> 2010-10-29 12:00:00 -0500 ;TI";Time.parse("12:00", dt) #=> 2010-10-30 12:00:00 -0500 ;TI";Time.parse("12:00", md) #=> 2010-10-31 12:00:00 -0500 ;T;0o; ;[ I"R#parse also accepts an optional block. You can use this block to specify how ;TI"Qto handle the year component of the date. This is specifically designed for ;TI"Qhandling two digit years. For example, if you wanted to treat all two digit ;TI">years prior to 70 as the year 2000+ you could write this:;T@o;;[ I"FTime.parse("01-10-31") {|year| year + (year < 70 ? 2000 : 1900)} ;TI"##=> 2001-10-31 00:00:00 -0500 ;TI"FTime.parse("70-10-31") {|year| year + (year < 70 ? 2000 : 1900)} ;TI"##=> 1970-10-31 00:00:00 -0500 ;T;0S;; i;I"Time.strptime;T@o; ;[I"Q#strptime works similar to +parse+ except that instead of using a heuristic ;TI"Rto detect the format of the input string, you provide a second argument that ;TI"5describes the format of the string. For example:;T@o;;[I"JTime.strptime("2000-10-31", "%Y-%m-%d") #=> 2000-10-31 00:00:00 -0500;T;0; I"lib/time.rb;T;0o;;[0o; ;[I"MTime is an abstraction of dates and times. Time is stored internally as ;TI"Lthe number of seconds with fraction since the _Epoch_, January 1, 1970 ;TI"L00:00 UTC. Also see the library module Date. The Time class treats GMT ;TI"O(Greenwich Mean Time) and UTC (Coordinated Universal Time) as equivalent. ;TI"OGMT is the older way of referring to these baseline times but persists in ;TI")the names of calls on POSIX systems.;T@o; ;[I"MAll times may have fraction. Be aware of this fact when comparing times ;TI"Nwith each other -- times that are apparently equal when displayed may be ;TI"different when compared.;T@o; ;[I"ISince Ruby 1.9.2, Time implementation uses a signed 63 bit integer, ;TI"Bignum or Rational. ;TI"HThe integer is a number of nanoseconds since the _Epoch_ which can ;TI")represent 1823-11-12 to 2116-02-20. ;TI"EWhen Bignum or Rational is used (before 1823, after 2116, under ;TI"<nanosecond), Time works slower as when integer is used.;T@S;; i;I" Examples;T@o; ;[I"KAll of these examples were done using the EST timezone which is GMT-5.;T@S;; i;I"!Creating a new Time instance;T@o; ;[I"MYou can create a new instance of Time with Time::new. This will use the ;TI"Gcurrent system time. Time::now is an alias for this. You can also ;TI"Ppass parts of the time to Time::new such as year, month, minute, etc. When ;TI"Qyou want to construct a time this way you must pass at least a year. If you ;TI"Qpass the year with nothing else time will default to January 1 of that year ;TI"Jat 00:00:00 with the current system timezone. Here are some examples:;T@o;;[ I":Time.new(2002) #=> 2002-01-01 00:00:00 -0500 ;TI":Time.new(2002, 10) #=> 2002-10-01 00:00:00 -0500 ;TI":Time.new(2002, 10, 31) #=> 2002-10-31 00:00:00 -0500 ;TI"MTime.new(2002, 10, 31, 2, 2, 2, "+02:00") #=> 2002-10-31 02:02:02 +0200 ;T;0o; ;[I"&You can also use #gm, #local and ;TI"A#utc to infer GMT, local and UTC timezones instead of using ;TI" the current system setting.;T@o; ;[I"MYou can also create a new time using Time::at which takes the number of ;TI"6seconds (or fraction of seconds) since the {Unix ;TI"4Epoch}[http://en.wikipedia.org/wiki/Unix_time].;T@o;;[I"6Time.at(628232400) #=> 1989-11-28 00:00:00 -0500 ;T;0S;; i;I"%Working with an instance of Time;T@o; ;[I"NOnce you have an instance of Time there is a multitude of things you can ;TI"Pdo with it. Below are some examples. For all of the following examples, we ;TI"Bwill work on the assumption that you have done the following:;T@o;;[I"4t = Time.new(1993, 02, 24, 12, 0, 0, "+09:00") ;T;0o; ;[I"Was that a monday?;T@o;;[I"t.monday? #=> false ;T;0o; ;[I"What year was that again?;T@o;;[I"t.year #=> 1993 ;T;0o; ;[I")Was is daylight savings at the time?;T@o;;[I"t.dst? #=> false ;T;0o; ;[I"!What's the day a year later?;T@o;;[I"6t + (60*60*24*365) #=> 1994-02-24 12:00:00 +0900 ;T;0o; ;[I"4How many seconds was that since the Unix Epoch?;T@o;;[I"t.to_i #=> 730522800 ;T;0o; ;[I"?You can also do standard functions like compare two times.;T@o;;[I"t1 = Time.new(2010) ;TI"t2 = Time.new(2011) ;TI" ;TI"t1 == t2 #=> false ;TI"t1 == t1 #=> true ;TI"t1 < t2 #=> true ;TI"t1 > t2 #=> false ;TI" ;TI"3Time.new(2010,10,31).between?(t1, t2) #=> true;T;0; I"time.c;T;0; 0;0[ [ [[I"Comparable;To;;[ ; @�;0I"time.c;T[[I" class;T[[:public[ [I"at;T@[I"gm;T@[I"json_create;FI""ext/json/lib/json/add/time.rb;T[I" local;T@[I"mktime;T@[I"new;T@[I"now;T@[I"utc;T@[:protected[ [:private[ [I" instance;T[[;[I[I"+;T@[I"-;T@[I"<=>;TI"lib/rake/ext/time.rb;T[I"as_json;F@[I"asctime;T@[I" ctime;T@[I"day;T@[I" dst?;T@[I" eql?;T@[I"friday?;T@[I" getgm;T@[I" getlocal;T@[I"getutc;T@[I" gmt?;T@[I"gmt_offset;T@[I"gmtime;T@[I"gmtoff;T@[I" hash;T@[I" hour;T@[I" httpdate;FI"lib/time.rb;T[I"inspect;T@[I" isdst;T@[I"iso8601;F@P[I"localtime;T@[I" mday;T@[I"min;T@[I"mon;T@[I"monday?;T@[I" month;T@[I" nsec;T@[I" parse;F@P[I"rake_original_time_compare;F@-[I"rfc2822;F@P[I"rfc822;F@P[I" round;T@[I"saturday?;T@[I"sec;T@[I" strftime;T@[I" strptime;F@P[I"subsec;T@[I" succ;T@[I"sunday?;T@[I"thursday?;T@[I" to_a;T@[I"to_date;TI"ext/date/date_core.c;T[I"to_datetime;T@�[I" to_f;T@[I" to_i;T@[I"to_json;F@[I" to_r;T@[I" to_s;T@[I"to_time;T@�[I" tuesday?;T@[I"tv_nsec;T@[I"tv_sec;T@[I"tv_usec;T@[I" usec;T@[I"utc;T@[I" utc?;T@[I"utc_offset;T@[I"w3cdtf;FI"lib/rss/rss.rb;T[I" wday;T@[I"wednesday?;T@[I"xmlschema;F@P[I" yday;T@[I" year;T@[I" zone;T@[I"zone_offset;F@P[;[ [;[ [I"apply_offset;F@P[I"make_time;F@P[I"month_days;F@P[I"zone_utc?;F@P[ [U:RDoc::Context::Section[i 0o;;[ ; 0;0[I"ext/date/date_core.c;T@I"lib/cgi/session.rb;T@@@�@�@�cRDoc::TopLevel