Skip to content

Commit

Permalink
Fix #wday_in_month for floraison/fugit#67
Browse files Browse the repository at this point in the history
  • Loading branch information
jmettraux committed Mar 9, 2022
1 parent f9701f3 commit 0954c4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## et-orbi 1.2.7 not yet released

- Fix the wday_in_month computation for floraison/fugit#67


## et-orbi 1.2.6 released 2021-10-30

Expand Down
8 changes: 5 additions & 3 deletions lib/et-orbi/time.rb
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ def localtime(zone=nil)

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
Expand Down Expand Up @@ -385,10 +386,11 @@ 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)
Expand Down

0 comments on commit 0954c4d

Please sign in to comment.