Project

General

Profile

Bug #3514 » date.patch

runpaint (Run Paint Run Run), 07/02/2010 04:38 AM

View differences:

lib/date.rb
end
def jd_to_weeknum(jd, f=0, sg=GREGORIAN) # :nodoc:
y, m, d = jd_to_civil(jd, sg)
y, _, d = jd_to_civil(jd, sg)
a = find_fdoy(y, sg) + 6
w, d = (jd - (a - ((a - f) + 1) % 7) + 7).divmod(7)
return y, w, d
......
end
def jd_to_nth_kday(jd, sg=GREGORIAN) # :nodoc:
y, m, d = jd_to_civil(jd, sg)
y, m, = jd_to_civil(jd, sg)
j = find_fdom(y, m, sg)
return y, m, ((jd - j) / 7).floor + 1, jd_to_wday(jd)
end
......
d += 8
end
if w < 0
ny, nw, nd =
ny, nw, =
jd_to_commercial(commercial_to_jd(y + 1, 1, 1, sg) + w * 7, sg)
return unless ny == y
w = nw
......
d += 7
end
if w < 0
ny, nw, nd, nf =
ny, nw, =
jd_to_weeknum(weeknum_to_jd(y + 1, 1, f, f, sg) + w * 7, f, sg)
return unless ny == y
w = nw
......
if n < 0
ny, nm = (y * 12 + m).divmod(12)
nm, = (nm + 1) .divmod(1)
ny, nm, nn, nk =
ny, nm, nn, =
jd_to_nth_kday(nth_kday_to_jd(ny, nm, 1, k, sg) + n * 7, sg)
return unless [ny, nm] == [y, m]
n = nn
(1-1/8)