timesteps 1.0.6 → 1.0.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: 1e933e2020424ed914b88472cafe4e2c7634dd6afe07475f4b0b915689fe4693
4
- data.tar.gz: be0df225f53617124a675c374f41f47924da31926043a859f548e3d563bf5f6c
3
+ metadata.gz: f2250572f5f280515d33d4928c198739ba3f5ba9c69ad3dfeb64ee55d982a206
4
+ data.tar.gz: 38a8b7b8e6339cfa77665c60194eab228ccb2eabdae71617955a0fe2beb2b303
5
5
  SHA512:
6
- metadata.gz: 61c5653b8eb7b6423c92abdc89e331aac3f8675732ffc424fb34268bb6b69b24b63d7eaefdd121d4a3e28a3ecf1bd726a5a28639f25ce3f705039b5fb9fd6f32
7
- data.tar.gz: 17015550f19920f9ce2c80e7a8e5df53f80deb44d7d6b6842f3eacd89d0eaf41cf2627274191767bacfbecd670630bdff1b95d2b8add41894eae34aeb9951289
6
+ metadata.gz: 5d21b7ad3e786ffca4966c9c7be8637ee316dd91a0e8bf9703c59ccb054c18cd4e3be9fb50f1056b07fac6e7d0391f4718123aeab677ceb2a62801289c810996
7
+ data.tar.gz: 56462ea294eab5163d9bad21b36939bc3f6cb02204c02efccdc697def79b03298d5de517cabc1ecc1ff5dc0a507217903e23e79e098aea8c801f2868600d2a1a
@@ -45,6 +45,10 @@ class DateTime
45
45
  mday = 1
46
46
  rest = $4
47
47
  hash = DateTime._parse("#{year}-#{month}-#{mday} 00:00:00 #{rest}")
48
+ elsif spec =~ /\A(\d{1,2}:\d{2}(:\d{2})?)\s*([+\-]\d{1,2}(:\d{2})?)?\z/
49
+ time = $1
50
+ offset = $3 || ""
51
+ hash = DateTime._parse("1970-01-01 #{time}#{offset}")
48
52
  else
49
53
  hash = DateTime._parse(spec)
50
54
  end
@@ -309,6 +309,18 @@ class TimeStep
309
309
  return @origin.offset
310
310
  end
311
311
 
312
+ # Returns the timestep object with new_offset
313
+ #
314
+ # @return [TimeStep]
315
+ #
316
+ def new_offset (offset)
317
+ obj = clone
318
+ obj.instance_eval {
319
+ @origin = @origin.new_offset(offset)
320
+ }
321
+ return obj
322
+ end
323
+
312
324
  # Parses datetime string and return datetime object.
313
325
  # In the parsing, the calendar of the object is used.
314
326
  # If `format` option is given, `strptime` method is
@@ -135,6 +135,10 @@ describe "TimeStep.new" do
135
135
  is_asserted_by { TimeStep.new("sec").origin == DateTime.new(1970,1,1) }
136
136
 
137
137
  end
138
+
139
+ example 'without since hh:mm+hh:mm' do
140
+ is_asserted_by { TimeStep.new("3 hours since 02:00").origin == DateTime.new(1970,1,1,2,0) }
141
+ end
138
142
 
139
143
  example 'since option with format' do
140
144
 
@@ -503,3 +507,5 @@ describe "TimeStep#truncate" do
503
507
  end
504
508
 
505
509
  end
510
+
511
+
data/timesteps.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  Gem::Specification::new do |s|
3
- version = '1.0.6'
3
+ version = '1.0.8'
4
4
 
5
5
  files = Dir.glob('**/*') + ['.yardopts'] - [
6
6
  Dir.glob('timesteps-*.gem'),
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timesteps
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Motoyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tzinfo