⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.93
Server IP:
65.108.141.171
Server:
Linux server.heloix.com 5.4.0-214-generic #234-Ubuntu SMP Fri Mar 14 23:50:27 UTC 2025 x86_64
Server Software:
Apache
PHP Version:
7.4.33
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
ri
/
2.7.0
/
system
/
Time
/
Edit File: parse-c.ri
U:RDoc::AnyMethod[iI" parse:ETI"Time::parse;TT:publico:RDoc::Markup::Document:@parts[!o:RDoc::Markup::Paragraph; [I"FTakes a string representation of a Time and attempts to parse it ;TI"using a heuristic.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"require 'time' ;TI" ;TI"<Time.parse("2010-10-31") #=> 2010-10-31 00:00:00 -0500 ;T:@format0o; ; [I"KAny missing pieces of the date are inferred based on the current date.;T@o;; [ I"require 'time' ;TI" ;TI"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"require 'time' ;TI" ;TI"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"DIf a block is given, the year described in +date+ is converted ;TI"Cby the block. This is specifically designed for handling two ;TI"Ddigit 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"require 'time' ;TI" ;TI"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; 0o; ; [I"OIf the upper components of the given time are broken or missing, they are ;TI"Jsupplied with those of +now+. For the lower components, the minimum ;TI"Dvalues (1 or 0) are assumed if broken or missing. For example:;T@o;; [I"require 'time' ;TI" ;TI"8# Suppose it is "Thu Nov 29 14:33:20 2001" now and ;TI"-# your time zone is EST which is GMT-5. ;TI"2now = Time.parse("Thu Nov 29 14:33:20 2001") ;TI"@Time.parse("16:30", now) #=> 2001-11-29 16:30:00 -0500 ;TI"@Time.parse("7/23", now) #=> 2001-07-23 00:00:00 -0500 ;TI"@Time.parse("Aug 31", now) #=> 2001-08-31 00:00:00 -0500 ;TI"@Time.parse("Aug 2000", now) #=> 2000-08-01 00:00:00 -0500 ;T; 0o; ; [ I"HSince there are numerous conflicts among locally defined time zone ;TI"Fabbreviations all over the world, this method is not intended to ;TI"Eunderstand all of them. For example, the abbreviation "CST" is ;TI"used variously as:;T@o;; [I" -06:00 in America/Chicago, ;TI"-05:00 in America/Havana, ;TI"+08:00 in Asia/Harbin, ;TI"!+09:30 in Australia/Darwin, ;TI"#+10:30 in Australia/Adelaide, ;TI" etc. ;T; 0o; ; [ I"DBased on this fact, this method only understands the time zone ;TI"Iabbreviations described in RFC 822 and the system time zone, in the ;TI"Eorder named. (i.e. a definition in RFC 822 overrides the system ;TI"@time zone definition.) The system time zone is taken from ;TI".<tt>Time.local(year, 1, 1).zone</tt> and ;TI"+<tt>Time.local(year, 7, 1).zone</tt>. ;TI"IIf the extracted time zone abbreviation does not match any of them, ;TI"Bit is ignored and the given time is regarded as a local time.;T@o; ; [I"LArgumentError is raised if Date._parse cannot extract information from ;TI"A+date+ or if the Time class cannot represent specified date.;T@o; ; [I"IThis method can be used as a fail-safe for other parsing methods as:;T@o;; [I"0Time.rfc2822(date) rescue Time.parse(date) ;TI"1Time.httpdate(date) rescue Time.parse(date) ;TI"2Time.xmlschema(date) rescue Time.parse(date) ;T; 0o; ; [I"7A failure of Time.parse should be checked, though.;T@o; ; [I"0You must require 'time' to use this method.;T: @fileI"lib/time.rb;T:0@omit_headings_from_table_of_contents_below00I" year;T[ I"(date, now=self.now);T@{FI" Time;TcRDoc::NormalClass00
Simpan