lib/et-orbi/time.rb in et-orbi-1.2.6 vs lib/et-orbi/time.rb in et-orbi-1.2.7
- old
+ new
@@ -324,11 +324,12 @@
alias translate localtime
alias in_time_zone localtime
def wday_in_month
- [ count_weeks(-1), - count_weeks(1) ]
+ [ count_weeks(EtOrbi.make_time(strftime('%F 12:00:00 %/Z')), -1),
+ - count_weeks(EtOrbi.make_time(strftime('%F 12:00:00 %/Z')) , 1) ]
end
def rweek
((self - EtOrbi.make_time('2019-01-01 00:00:00', @zone)) / WEEK_S)
@@ -383,13 +384,14 @@
def to_time
@time ||= @zone.utc_to_local(utc)
end
- def count_weeks(dir)
+ def count_weeks(start, dir)
c = 0
- t = self
+ t = start
+
until t.month != self.month
c += 1
t += dir * (7 * 24 * 3600)
end