timecop 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 016ae208ea8ac5c5713b042c7ea1f030bd2d3ff312e95b349e3d31264fc0f0d4
4
- data.tar.gz: ed69f4b76ca2a02af2c10f4ad486140bbfefae3d1f3ac13f2d0e7a9176ba09d8
3
+ metadata.gz: ad1963ee820d4d3519b4e078879aaa3914b2e9802460480fd9ca3c4a239677e4
4
+ data.tar.gz: 49a827fc02c8580d33d6861f51974dd046996e7281442c33f89c527d4d4c5af0
5
5
  SHA512:
6
- metadata.gz: f47a6e763afa59b037e5e00250b63a623cf3e605135962ecca5bd7eba9e7e36db669c8c261dcefc52ee6c852f1a1507977d5266ad1c63bd007d1edc50414ea1e
7
- data.tar.gz: b4a3bff764722b9d1c95d0e7f01dbdad3953503d87e4587c02ad12c0fc5ebe47598177cafdd4d81b9dfaee6ef76447a2e15f5382403cad224fbe08221886fc90
6
+ metadata.gz: d18895efbc69f3768fcf68fa372759e727c30869e5ff1a77c8b7a2901e4a89dd49fe61df38c0a5c57dd9604250e0c49733c990c32757ac9a374a56fb3962d441
7
+ data.tar.gz: 6938b5dfc45c545d8c0e83b757f1b99d9b69b2cfe23d5e1d0f9b4fc4ff56282af201a982bcf52084f05b0de88ea36256ecbe54e2988fc944693940f5179dcb97
@@ -58,14 +58,21 @@ class Date #:nodoc:
58
58
  Date.new(year, mon, d[:mday], start)
59
59
  elsif d[:yday]
60
60
  Date.new(year, 1, 1, start).next_day(d[:yday] - 1)
61
- elsif d[:cwyear] || d[:cweek] || d[:wnum1] || d[:wday] || d[:cwday]
62
- day_of_week_from_monday = if d[:wday]
63
- (d[:wday] + 6)%7 + 1
64
- else
65
- d[:cwday] || 1
66
- end
67
- week = d[:cweek] || d[:wnum1] || now.strftime('%W').to_i
68
- Date.commercial(year, week, day_of_week_from_monday, start)
61
+ elsif d[:cwyear] || d[:cweek] || d[:wnum0] || d[:wnum1] || d[:wday] || d[:cwday]
62
+ week = d[:cweek] || d[:wnum1] || d[:wnum0] || now.strftime('%W').to_i
63
+ if d[:wnum0] #Week of year where week starts on sunday
64
+ if d[:cwday] #monday based day of week
65
+ Date.strptime_without_mock_date("#{year} #{week} #{d[:cwday]}", '%Y %U %u', start)
66
+ else
67
+ Date.strptime_without_mock_date("#{year} #{week} #{d[:wday] || 0}", '%Y %U %w', start)
68
+ end
69
+ else #Week of year where week starts on monday
70
+ if d[:wday] #sunday based day of week
71
+ Date.strptime_without_mock_date("#{year} #{week} #{d[:wday]}", '%Y %W %w', start)
72
+ else
73
+ Date.strptime_without_mock_date("#{year} #{week} #{d[:cwday] || 1}", '%Y %W %u', start)
74
+ end
75
+ end
69
76
  elsif d[:seconds]
70
77
  Time.at(d[:seconds]).to_date
71
78
  else
@@ -56,7 +56,7 @@ class Timecop
56
56
 
57
57
  def time(time_klass = Time) #:nodoc:
58
58
  if @time.respond_to?(:in_time_zone)
59
- time = time_klass.at(@time.localtime)
59
+ time = time_klass.at(@time.dup.localtime)
60
60
  else
61
61
  time = time_klass.at(@time)
62
62
  end
@@ -1,3 +1,3 @@
1
1
  class Timecop
2
- VERSION = "0.9.7"
2
+ VERSION = "0.9.8"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timecop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Jeffery
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-08-12 00:00:00.000000000 Z
12
+ date: 2023-08-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A gem providing "time travel" and "time freezing" capabilities, making
15
15
  it dead simple to test time-dependent code. It provides a unified method to mock