diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-07-06 07:21:26 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-07-06 07:21:26 +0000 |
commit | d1375688cdde3d094984f7f3a7bffe57306a0bca (patch) | |
tree | f5320945b9bfd9fc19b133335a7be45076fe03e9 /lib | |
parent | a60db057a2a8456f8f5b59a6c5805e25d1d47d34 (diff) |
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/date.rb | 54 | ||||
-rw-r--r-- | lib/mkmf.rb | 4 | ||||
-rw-r--r-- | lib/profile.rb | 1 | ||||
-rw-r--r-- | lib/tempfile.rb | 2 |
4 files changed, 54 insertions, 7 deletions
diff --git a/lib/date.rb b/lib/date.rb index 9de49bcbc7..3a7d3c7b1b 100644 --- a/lib/date.rb +++ b/lib/date.rb @@ -1,8 +1,8 @@ # # Date.rb - # $Release Version: $ -# $Revision: 1.1.1.1.4.5 $ -# $Date: 1998/03/03 02:39:34 $ +# $Revision: 1.1.1.2 $ +# $Date: 1999/01/20 04:59:35 $ # by Yasuo OHBA(SHL Japan Inc. Technology Dept.) # # -- @@ -64,14 +64,17 @@ class Date def month return @month end + alias mon month def day return @day end + alias mday day def period return Date.period!(@year, @month, @day) end + protected :period def jd return period + 1721423 @@ -89,10 +92,15 @@ class Date to_s end - def day_of_week + def wday return (period + 5) % 7 end - + alias day_of_week wday + + def yday + return period - Date.new(@year-1,12,31).period + end + def name_of_week return Weektag[self.day_of_week] end @@ -148,9 +156,10 @@ class Date return @year ^ @month ^ @day end - def leapyear? + def leap? Date.leapyear(@year) != 1 end + alias leapyear? leap? def _check_date if @year == nil or @month == nil or @day == nil @@ -176,6 +185,31 @@ class Date end return self end + + def << (n) + self >> -n + end + + def >> (n) + y = @year + m = @month-1 + d = @day + + m += n + y += m/12 + m = m%12 + m += 1 + + if y == 1752 && m == 9 && d >= 3 && d <= 13 + d = 2 + else + lasts = Date.daylist(y) + if d > lasts[m] + d = lasts[m] + end + end + Date.new(y,m,d) + end private :_check_date end @@ -213,6 +247,15 @@ def Date.at(d) return Date.new(yy, mm, dd) end +def Date.new3(year,mon=1,day=1) + Date.new(year,mon,day) +end + +def Date.today + Date.new(*Time.now.to_a[3,3].reverse!) +end + +## private class methods - do not call def Date.period!(y, m, d) p = d dl = Date.daylist(y) @@ -256,3 +299,4 @@ def Date.jan1!(y) end return (d % 7) end + diff --git a/lib/mkmf.rb b/lib/mkmf.rb index c042561e13..ae593224e9 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -406,7 +406,11 @@ TARGET = #{target} DLLIB = $(TARGET).#{CONFIG["DLEXT"]} RUBY = #{CONFIG["ruby_install_name"]} +<<<<<<< mkmf.rb +RM = $(RUBY) -r ftools -e 'File::rm_f *Dir[ARGV.join(" ")]' +======= RM = $(RUBY) -r ftools -e 'File::rm_f(*Dir[ARGV.join(" ")])' +>>>>>>> 1.22 EXEEXT = #{CONFIG["EXEEXT"]} diff --git a/lib/profile.rb b/lib/profile.rb index d94b09da9e..b00caac42e 100644 --- a/lib/profile.rb +++ b/lib/profile.rb @@ -49,7 +49,6 @@ module Profiler__ f.printf "%6.2f %8.2f %8.2f %8d ", d[2]/total*100, sum, d[2], d[0] f.printf "%8.2f %8.2f %s\n", d[2]*1000/d[0], d[1]*1000/d[0], d[3] end - p total f.close } set_trace_func p diff --git a/lib/tempfile.rb b/lib/tempfile.rb index c432285309..0e4c99e5ff 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -52,7 +52,7 @@ class Tempfile < SimpleDelegator @clean_files = Tempfile.callback(tmpname, @protect) ObjectSpace.define_finalizer(self, @clean_files) - @tmpfile = File.open(tmpname, 'w+') + @tmpfile = File.open(tmpname, File::RDWR|File::CREAT|File::EXCL) @protect[0] = @tmpfile @tmpname = tmpname super(@tmpfile) |