timesteps 1.0.1 → 1.0.2

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: 9f12b99565a7b2bdc24a8e9c6e3d2b38a439d3b273f73df6af514f1bee2c7905
4
- data.tar.gz: e2680119ef10f30ea98803e89e9dd2e6f0b9d0b9291939100896ce3c192d0b86
3
+ metadata.gz: 6700d400608b814af5cd0fcc0136f8ef717a6e26939a1d91cf37abf65a7afa94
4
+ data.tar.gz: 3c34321b6468f3136732a3b6e16137486f6fcb1710049e07d208a663048b0730
5
5
  SHA512:
6
- metadata.gz: ffca26ce458c6867518d4804e50fa85e673c972e32941299697b19a49b20baba1731a9d512d566bffa4532870a4e0f229e154c61d20e8b3ad1ec94e95d3ba2fc
7
- data.tar.gz: a1b3f59a940a30d3e7634cdbbb748fa39f45558ce0ac65412b8630c2a847293f708dc8fbe85760eb13f4462d82067e2c677dac84ba0b6cfafed48622b10cea90
6
+ metadata.gz: dc989ec56ef1812a6d8afc2e4e6d6b70b6b67d6490a88a5db5a38eb3942a80ba28fb61c968f29242dc562b039524943ec6fadd43adfd57c70a1b2b80880c378b
7
+ data.tar.gz: bcfcf00eeb435e11d9a4fbc7366050f048acb1478c46cbdb9bc40175dabf32b80ba0777f18d4ec7582deaa0077ea5ee7558ef3dd3847c5ff44a44da334cb78cd
data/NEWS.md CHANGED
@@ -1,6 +1,12 @@
1
1
  NEWS
2
2
  ====
3
3
 
4
+ 0.9.9 -> 1.0.2
5
+ --------------
6
+
7
+ * [Add] DateTime#next, DateTime#prev
8
+ * [Add] TimeStep#right_time?
9
+
4
10
  0.9.8 -> 0.9.9
5
11
  --------------
6
12
 
data/Note.ja.md CHANGED
@@ -4,8 +4,6 @@ masterブランチ -> gem リリース最新版
4
4
  developブランチ -> 開発統合版
5
5
  topicブランチ -> Feature開発版
6
6
 
7
-
8
-
9
7
  "XX since YYY" と since: time を同時に指定下場合は、前者が採用される (sinceオプションは無視される)。
10
8
 
11
9
  ### 時間の単位 (udunits)
data/README.md CHANGED
@@ -1,10 +1,14 @@
1
- timesteps
1
+ TimeSteps
2
2
  ================
3
3
 
4
4
  A library for handling discrete time series in constant increments.
5
5
  The primary purpose is to describe the time axis
6
6
  when dealing with time series of observational data and climate data.
7
7
 
8
+ This library relies heavily on the DateTime class. However,
9
+ the DateTime class has been deprecated,
10
+ so please keep that in mind when using this library.
11
+
8
12
  Features
9
13
  --------
10
14
 
@@ -25,6 +25,34 @@ class DateTime
25
25
  return TimePeriod.new(interval_spec, since: self, calendar: calendar, ends: ends, tz: tz)
26
26
  end
27
27
 
28
+ def next (*args)
29
+ case args.size
30
+ when 1
31
+ num = 1
32
+ unit = args[0]
33
+ when 2
34
+ num = args[0]
35
+ unit = args[1]
36
+ else
37
+ raise "invalid number of argumets"
38
+ end
39
+ return TimeStep.new(unit, since: self).time_at(num)
40
+ end
41
+
42
+ def prev (*args)
43
+ case args.size
44
+ when 1
45
+ num = 1
46
+ unit = args[0]
47
+ when 2
48
+ num = args[0]
49
+ unit = args[1]
50
+ else
51
+ raise "invalid number of argumets"
52
+ end
53
+ return TimeStep.new(unit, since: self).time_at(-num)
54
+ end
55
+
28
56
  end
29
57
 
30
58
  class DateTime::NoLeap
@@ -697,5 +697,19 @@ class TimeStep
697
697
  return TimeStep::Range.new(self, start, last, count: count, ends: ends)
698
698
  end
699
699
 
700
+ # Check whether the given time is right or not for timestep.
701
+ #
702
+ # @example
703
+ # ts = TimeStep.new("1 hour")
704
+ # ts.right_time?(ts.parse("2001-01-01 01:00:00"))
705
+ # # => true
706
+ # ts.right_time?(ts.parse("2001-01-01 01:30:00"))
707
+ # # => false
708
+ #
709
+ # @return [TimeStep::Range]
710
+ def right_time? (time)
711
+ return index_at(time).integer?
712
+ end
713
+
700
714
  end
701
715
 
@@ -25,7 +25,7 @@ class TimeStep::Range
25
25
  when Time
26
26
  last = timestep.index_at(last.to_datetime)
27
27
  when DateTime, DateTimeLike, String
28
- last = timestep.index_at(last)
28
+ last = timestep.index_at(last)
29
29
  else
30
30
  raise "unknown argument"
31
31
  end
@@ -436,3 +436,16 @@ describe "TimeStep#new_origin" do
436
436
 
437
437
  end
438
438
 
439
+
440
+ describe "TimeStep#right_time?" do
441
+
442
+ example do
443
+
444
+ ts = TimeStep.new("1 hour")
445
+ is_asserted_by { ts.right_time?(ts.parse("2001-01-01 01:00:00")) == true }
446
+ is_asserted_by { ts.right_time?(ts.parse("2001-01-01 01:30:00")) == false }
447
+
448
+ end
449
+
450
+ end
451
+
data/timesteps.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  Gem::Specification::new do |s|
3
- version = "1.0.1"
3
+ version = "1.0.2"
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.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroki Motoyoshi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-28 00:00:00.000000000 Z
11
+ date: 2021-12-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " A library for time conversion and intercomparison of multiple time
14
14
  series data \n in the case of handling time series data of the type that specifies