evt-clock 1.0.0.0 → 1.1.0.0

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: 7637dfa2cf95640025399723df9be54a41ce8df6a9a344b1966de329689ee54e
4
- data.tar.gz: e410017a71157bf0d28b79052a7b922fab37a6a03cb432797f5e56343f2ceb8e
3
+ metadata.gz: 18cd791a361b8dde3b2f16358da521edccbf60c0db2566d57129062ec97f6e61
4
+ data.tar.gz: 2163bbb923eabc2da8d0d439a9b8893e4d7df7c8635237bc9364637c93129ec3
5
5
  SHA512:
6
- metadata.gz: fa542ec307f560af14b86f1e0fcab14bb784bacaf4e8ceabd9a7a2a59702340843db3b0762b0af656bdc629371c8203a6aeb236df46416c32659aff62497d4a1
7
- data.tar.gz: c7d7986934c7cc7050b50710d3af72141c097fc39369f23041fedbcf3deaf479fbb44efd2e3c21bd036d632b9a3415fc0825e0f13ad9a33e74210baf8fd1293f
6
+ metadata.gz: 343481cf0000c466a2d0b745e1bf0d7f004f4e3b54ef5ce3a74cfac3da9d7209f5ed9d133d14c70e973d5aa597deb70c9f9f5cea9bc6938b6bb10b06881233d4
7
+ data.tar.gz: bd863fbe05b98c0641e405d80f2485c993ab6b732f342cb56a7934abee0f78e0d38be74585dc36ee00839f9dcc716510fe5367b2104e8a9de5683375d571217c
data/lib/clock.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'time'
2
- require 'tzinfo'
3
2
  require 'ostruct'
4
3
  require 'naught'
5
4
 
@@ -7,5 +6,3 @@ require 'clock/clock'
7
6
  require 'clock/substitute'
8
7
  require 'clock/utc'
9
8
  require 'clock/local'
10
- require 'clock/localized'
11
- require 'clock/localized/timezone'
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evt-clock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.0
4
+ version: 1.1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The Eventide Project
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-04 00:00:00.000000000 Z
11
+ date: 2018-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: tzinfo
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: naught
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -64,8 +50,6 @@ files:
64
50
  - lib/clock/controls/time.rb
65
51
  - lib/clock/controls/time/offset.rb
66
52
  - lib/clock/local.rb
67
- - lib/clock/localized.rb
68
- - lib/clock/localized/timezone.rb
69
53
  - lib/clock/substitute.rb
70
54
  - lib/clock/utc.rb
71
55
  homepage: https://github.com/eventide-project/clock
@@ -1,60 +0,0 @@
1
- module Clock
2
- class Localized
3
- class Timezone
4
- attr_reader :tzinfo_timezone
5
- attr_reader :utc_reference
6
-
7
- def initialize(tzinfo_timezone, utc_reference)
8
- @tzinfo_timezone = tzinfo_timezone
9
- @utc_reference = utc_reference
10
- end
11
-
12
- def self.build(timezone_identifier=nil, utc_reference: nil)
13
- utc_reference ||= Time.now.utc
14
-
15
- timezone_identifier = Defaults.timezone_identifier(timezone_identifier)
16
- tzinfo_timezone = TZInfo::Timezone.get(timezone_identifier)
17
-
18
- new tzinfo_timezone, utc_reference
19
- end
20
-
21
- def period
22
- tzinfo_timezone.period_for_utc utc_reference
23
- end
24
-
25
- def now(tzinfo_time=nil)
26
- tzinfo_time ||= tzinfo_timezone.now
27
- convert tzinfo_time
28
- end
29
-
30
- def utc_to_local(utc_time)
31
- tzinfo_time = tzinfo_timezone.utc_to_local utc_time
32
- convert tzinfo_time
33
- end
34
-
35
- def convert(tzinfo_time)
36
- seconds = tzinfo_time.sec + tzinfo_time.subsec
37
-
38
- Time.new(
39
- tzinfo_time.year,
40
- tzinfo_time.month,
41
- tzinfo_time.day,
42
- tzinfo_time.hour,
43
- tzinfo_time.min,
44
- seconds,
45
- offset
46
- )
47
- end
48
-
49
- def offset
50
- total_offset = period.offset.utc_total_offset
51
-
52
- hours, seconds = total_offset.abs.divmod 3600
53
- minutes = seconds / 60
54
-
55
- sign = total_offset > 0 ? '+' : '-'
56
- offset = "#{sign}#{hours.to_s.rjust(2, '0')}:#{minutes.to_s.rjust(2, '0')}"
57
- end
58
- end
59
- end
60
- end
@@ -1,60 +0,0 @@
1
- module Clock
2
- class Localized
3
- include Clock
4
-
5
- attr_reader :timezone
6
-
7
- def initialize(timezone)
8
- @timezone = timezone
9
- end
10
-
11
- def self.build(timezone_identifier=nil, utc_reference: nil)
12
- timezone = Timezone.build timezone_identifier, utc_reference: utc_reference
13
- new(timezone)
14
- end
15
-
16
- def self.configure(receiver, timezone_identifier=nil)
17
- instance = build(timezone_identifier)
18
- receiver.clock = instance
19
- instance
20
- end
21
-
22
- def system_time
23
- timezone
24
- end
25
-
26
- def self.canonize(time, system_time)
27
- time = time.utc
28
- system_time.utc_to_local time
29
- end
30
-
31
- def self.iso8601(time, precision: nil, system_time: nil)
32
- time ||= now time, system_time: system_time
33
- utc_time = time.utc
34
- local_time = system_time.utc_to_local utc_time
35
- local_time.iso8601 precision
36
- end
37
-
38
- module Defaults
39
- def self.timezone_identifier(timezone_identifier)
40
- env_identifier = ENV['TIMEZONE']
41
-
42
- if env_identifier
43
- timezone_identifier = env_identifier
44
- end
45
-
46
- unless timezone_identifier
47
- timezone_identifier = 'America/Mexico_City'
48
- end
49
-
50
- timezone_identifier
51
- end
52
- end
53
-
54
- module Substitute
55
- def self.build
56
- Clock::Substitute.new
57
- end
58
- end
59
- end
60
- end