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 +4 -4
- data/NEWS.md +6 -0
- data/Note.ja.md +0 -2
- data/README.md +5 -1
- data/lib/timesteps/datetime_timestep.rb +28 -0
- data/lib/timesteps/timestep.rb +14 -0
- data/lib/timesteps/timestep_range.rb +1 -1
- data/spec/timestep_spec.rb +13 -0
- data/timesteps.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6700d400608b814af5cd0fcc0136f8ef717a6e26939a1d91cf37abf65a7afa94
|
4
|
+
data.tar.gz: 3c34321b6468f3136732a3b6e16137486f6fcb1710049e07d208a663048b0730
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc989ec56ef1812a6d8afc2e4e6d6b70b6b67d6490a88a5db5a38eb3942a80ba28fb61c968f29242dc562b039524943ec6fadd43adfd57c70a1b2b80880c378b
|
7
|
+
data.tar.gz: bcfcf00eeb435e11d9a4fbc7366050f048acb1478c46cbdb9bc40175dabf32b80ba0777f18d4ec7582deaa0077ea5ee7558ef3dd3847c5ff44a44da334cb78cd
|
data/NEWS.md
CHANGED
data/Note.ja.md
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
|
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
|
data/lib/timesteps/timestep.rb
CHANGED
@@ -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
|
|
data/spec/timestep_spec.rb
CHANGED
@@ -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
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.
|
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-
|
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
|