zones 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/lib/zones.rb +66 -0
  4. data/zones.gemspec +1 -1
  5. metadata +6 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 93f46e66599119d3fc322a6f13b99004465fb68341036264e1d38e3c4c939a63
4
- data.tar.gz: 1dc9d208033d43fc909be86b210122149277f9c01b4c6561ecb271b14417b350
3
+ metadata.gz: 9e885735f5b158bc128438382c99bab2319a1717e3bee2582240c241c6a97d5d
4
+ data.tar.gz: 4ec9636d438698c2ee257904e01e8b6f2a48389fb1bfc0df06a935a031bbbe61
5
5
  SHA512:
6
- metadata.gz: df746b79666d56534e923d5e63b6690cf7b92a9f93cf646167c8e610e9d362967abffb07cf431bce3aa1fbfbbb468585a5901821f46c12fe0bdae990cc0a6da3
7
- data.tar.gz: b83975032a26e13b851f0efbd3cf3f136714c63ce62c9082e01351fd1661b761ff6c86a1e51290e316194797de736f30f5dc0c41b5bb059eeeb825c4eada6519
6
+ metadata.gz: c7791eeed90e65b247d6a3a2a841e6f2774f5381b4d3ab3e7c6c010e11eb7c271eb2ddeaed587275e05bbbe8c42b94d65fe6b66d7d41ce9caf82aee801fe54fd
7
+ data.tar.gz: 6935b6b8c8f7e9e92f7f2bdb6c30ab4f5ea65b2da7e07e7094b0b5a61aec9cb6d4510492f164015649f4fb2d2342fdc039593cd09ecec47d13b064457e622144
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.5.0
1
+ 2.6.5
data/lib/zones.rb CHANGED
@@ -1,5 +1,63 @@
1
1
  require "tzinfo"
2
2
 
3
+ # ==[ Dart uses the folllowing ]==
4
+
5
+ # /*
6
+ # * date ::= yeardate time_opt timezone_opt
7
+ # * yeardate ::= year colon_opt month colon_opt day
8
+ # * year ::= sign_opt digit{4,6}
9
+ # * colon_opt :: <empty> | ':'
10
+ # * sign ::= '+' | '-'
11
+ # * sign_opt ::= <empty> | sign
12
+ # * month ::= digit{2}
13
+ # * day ::= digit{2}
14
+ # * time_opt ::= <empty> | (' ' | 'T') hour minutes_opt
15
+ # * minutes_opt ::= <empty> | colon_opt digit{2} seconds_opt
16
+ # * seconds_opt ::= <empty> | colon_opt digit{2} millis_opt
17
+ # * micros_opt ::= <empty> | ('.' | ',') digit+
18
+ # * timezone_opt ::= <empty> | space_opt timezone
19
+ # * space_opt :: ' ' | <empty>
20
+ # * timezone ::= 'z' | 'Z' | sign digit{2} timezonemins_opt
21
+ # * timezonemins_opt ::= <empty> | colon_opt digit{2}
22
+ # */
23
+ # static final RegExp _parseFormat =
24
+ # RegExp(r'^([+-]?\d{4,6})-?(\d\d)-?(\d\d)' // Day part.
25
+ # r'(?:[ T](\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d+))?)?)?' // Time part.
26
+ # r'( ?[zZ]| ?([-+])(\d\d)(?::?(\d\d))?)?)?$'); // Timezone part.
27
+
28
+ class Date
29
+ def self.parse_str(str)
30
+ case str
31
+ when %r!^((?:19|20)\d\d)(\d\d)(\d\d)(\d\d)!
32
+ ymd = [$1.to_i, $2.to_i, $3.to_i]
33
+ when %r!^
34
+ (?:(0[1-9]|[12]\d|3[01]|[1-9][-/ ])[-/ ]? # $1: day
35
+ ((?>[a-z]{3,9}))[-/ ]? # $2: month
36
+ ((?>19|20)\d\d) # $3: year
37
+ | # or...
38
+ ((?>19|20)\d\d)[-/]? # $4: year
39
+ (0[1-9]|1[012]|[1-9][-/])[-/]? # $5: month
40
+ (0[1-9]|[12]\d|3[01]|[1-9][\sT]) # $6: day
41
+ | # or...
42
+ (0[1-9]|1[012]|[1-9][-/])[-/]? # $7: month
43
+ (0[1-9]|[12]\d|3[01]|[1-9][-/])[-/]? # $8: day
44
+ ((?>19|20)\d\d) # $9: year
45
+ )
46
+ !iox
47
+ ymd = $1 ? [$3.to_i, month_num($2), $1.to_i] : $4 ? [$4.to_i, $5.to_i, $6.to_i] : [$9.to_i, $7.to_i, $8.to_i]
48
+ else
49
+ raise "can't parse: #{str}"
50
+ end
51
+ ymd
52
+ end
53
+
54
+ # parse date
55
+ def self.to_day(str)
56
+ ymd = parse_str(str)
57
+ out = Date.new(*ymd)
58
+ end
59
+ end
60
+
3
61
  class Time
4
62
  def self.parse_str(str, ignore_offset=false)
5
63
  case str
@@ -95,4 +153,12 @@ class String
95
153
  def to_tz!(*args)
96
154
  Time.to_tz!(self, *args)
97
155
  end
156
+
157
+ def to_day
158
+ Date.to_day(self)
159
+ end
160
+
161
+ def to_day!(fmt="%Y-%m-%d")
162
+ to_day.strftime(fmt)
163
+ end
98
164
  end
data/zones.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "zones"
5
- s.version = "0.5.0"
5
+ s.version = "0.6.0"
6
6
  s.author = "Steve Shreeve"
7
7
  s.email = "steve.shreeve@gmail.com"
8
8
  s.summary = "Easy time parsing and conversion between time zones"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zones
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Shreeve
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-24 00:00:00.000000000 Z
11
+ date: 2021-09-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem makes it easy to work with time zones.
14
14
  email: steve.shreeve@gmail.com
@@ -26,7 +26,7 @@ homepage: https://github.com/shreeve/zones
26
26
  licenses:
27
27
  - MIT
28
28
  metadata: {}
29
- post_install_message:
29
+ post_install_message:
30
30
  rdoc_options: []
31
31
  require_paths:
32
32
  - lib
@@ -41,9 +41,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
41
  - !ruby/object:Gem::Version
42
42
  version: '0'
43
43
  requirements: []
44
- rubyforge_project:
45
- rubygems_version: 2.7.6
46
- signing_key:
44
+ rubygems_version: 3.2.16
45
+ signing_key:
47
46
  specification_version: 4
48
47
  summary: Easy time parsing and conversion between time zones
49
48
  test_files: []