time_crisis 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 1
4
- :patch: 5
4
+ :patch: 6
5
5
  :build:
@@ -7,8 +7,21 @@ class TimeCrisis::DateRange < Range
7
7
  options[:end] = args.shift unless args.empty?
8
8
  options[:exclude_end] = args.shift unless args.empty?
9
9
 
10
- start = options[:begin].nil? ? false : options[:begin].to_tc_date
11
- stop = options[:end].nil? ? false : options[:end].to_tc_date
10
+ start = if options[:begin].nil?
11
+ false
12
+ elsif options[:begin].is_a?(TimeCrisis::Date)
13
+ options[:begin]
14
+ else
15
+ options[:begin].to_tc_date
16
+ end
17
+
18
+ stop = if options[:end].nil?
19
+ false
20
+ elsif options[:end].is_a?(TimeCrisis::Date)
21
+ options[:end]
22
+ else
23
+ options[:end].to_tc_date
24
+ end
12
25
 
13
26
  unit = options[:unit] || 1
14
27
  scale = options[:scale] || 'years'
data/lib/time_crisis.rb CHANGED
@@ -7,9 +7,7 @@ end
7
7
 
8
8
  require 'third_base'
9
9
 
10
- module TimeCrisis
11
- include ThirdBase
12
- end
10
+ TimeCrisis = ThirdBase.dup
13
11
 
14
12
  # add needed bits of active support to time crisis
15
13
  # necessary now that it uses ThirdBase
@@ -21,3 +19,22 @@ require 'time_crisis/named_months'
21
19
  require 'time_crisis/weekend'
22
20
  require 'time_crisis/nth_weekday'
23
21
  require 'time_crisis/holiday'
22
+
23
+ # TODO: make this less of an ugly hack
24
+ module TimeCrisis
25
+ class DateTime
26
+ ENVMUTEX = Mutex.new
27
+ def for_zone(time_zone)
28
+ ENVMUTEX.synchronize do
29
+ original_zone = ENV['TZ']
30
+ begin
31
+ utc_time = self.to_time.utc
32
+ ENV['TZ'] = time_zone
33
+ utc_time.localtime.to_tc_datetime
34
+ ensure
35
+ ENV['TZ'] = original_zone
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
data/time_crisis.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{time_crisis}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Travis Tilley"]
12
- s.date = %q{2009-12-21}
12
+ s.date = %q{2009-12-22}
13
13
  s.description = %q{date and time related extensions}
14
14
  s.email = %q{ttilley@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: time_crisis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Tilley
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-21 00:00:00 -05:00
12
+ date: 2009-12-22 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency