wobbly 0.0.2 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/wobbly.rb +21 -22
- metadata +16 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3293e7a30ccf12e04f7492e3e23ac7e5653574aeb05f4129cb257b3336891da9
|
4
|
+
data.tar.gz: 554b484de14088b74a91901cf5af4a4c23aab9e343523f97f6f8a620dfaf3204
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b045ba4b69cd58e334fb5dbf9349f1e6931bbfe02b31a96c36eaf75ae1a5a35f8e2b5aa43e819b2e5a201d6e366f62f574a7cd42e3e2c1bd422a874de224f10
|
7
|
+
data.tar.gz: facb9eb2e4e834df372ba639659922b060e5f3b4cf4ea8d069a55ec6357b1a51c7b461583ddc1fae5c58f6ab03aa94a1a7652ca028531faa5b264d65eae99ff4
|
data/lib/wobbly.rb
CHANGED
@@ -9,30 +9,29 @@ module Wobbly
|
|
9
9
|
now = Time.now
|
10
10
|
|
11
11
|
tokens(s).each do |t|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
amt = token[0].to_i
|
17
|
-
seg = token[1].to_s
|
12
|
+
# Use regex match to directly capture amount and segment
|
13
|
+
amt, seg = t.match(/(\d+)([smhDMWY])/).captures
|
14
|
+
amt = amt.to_i
|
18
15
|
|
19
16
|
case seg
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
17
|
+
when 's'
|
18
|
+
now += amt
|
19
|
+
when 'm'
|
20
|
+
now += amt * 60
|
21
|
+
when 'h'
|
22
|
+
now += amt * 60 * 60
|
23
|
+
when 'D'
|
24
|
+
now += amt * 24 * 60 * 60
|
25
|
+
when 'W'
|
26
|
+
now += amt * 7 * 24 * 60 * 60
|
27
|
+
when 'M'
|
28
|
+
# Approximating 1 month as 30 days
|
29
|
+
now += amt * 30 * 24 * 60 * 60
|
30
|
+
when 'Y'
|
31
|
+
# Approximating 1 year as 365 days
|
32
|
+
now += amt * 365 * 24 * 60 * 60
|
33
|
+
else
|
34
|
+
raise ArgumentError, "Invalid time segment provided: #{seg}"
|
36
35
|
end
|
37
36
|
end
|
38
37
|
|
metadata
CHANGED
@@ -1,57 +1,46 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wobbly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Nieuwoudt
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 5.7.0
|
20
17
|
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
19
|
+
version: '5.25'
|
23
20
|
type: :development
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 5.7.0
|
30
24
|
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5.
|
26
|
+
version: '5.25'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rake
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
31
|
- - "~>"
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version:
|
40
|
-
- - ">="
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
version: 13.0.1
|
33
|
+
version: 13.2.1
|
43
34
|
type: :development
|
44
35
|
prerelease: false
|
45
36
|
version_requirements: !ruby/object:Gem::Requirement
|
46
37
|
requirements:
|
47
38
|
- - "~>"
|
48
39
|
- !ruby/object:Gem::Version
|
49
|
-
version:
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
description: Wobbly is an easy to use token type date parser in Ruby that allows you
|
54
|
-
easily parse short dates such as 1h2m
|
40
|
+
version: 13.2.1
|
41
|
+
description: Wobbly is a simple Ruby library that parses shorthand relative date and
|
42
|
+
time duration strings, making it easy to specify durations like '1h2m' (1 hour,
|
43
|
+
2 minutes) or '5Y' (5 years) in a concise format.
|
55
44
|
email: sean@isean.co.za
|
56
45
|
executables:
|
57
46
|
- wobbly
|
@@ -60,11 +49,11 @@ extra_rdoc_files: []
|
|
60
49
|
files:
|
61
50
|
- bin/wobbly
|
62
51
|
- lib/wobbly.rb
|
63
|
-
homepage: https://
|
52
|
+
homepage: https://github.com/sn/wobbly
|
64
53
|
licenses:
|
65
|
-
- GPL-3.0
|
54
|
+
- GPL-3.0-or-later
|
66
55
|
metadata: {}
|
67
|
-
post_install_message:
|
56
|
+
post_install_message:
|
68
57
|
rdoc_options: []
|
69
58
|
require_paths:
|
70
59
|
- lib
|
@@ -72,15 +61,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
61
|
requirements:
|
73
62
|
- - ">="
|
74
63
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
64
|
+
version: '2.7'
|
76
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
66
|
requirements:
|
78
67
|
- - ">="
|
79
68
|
- !ruby/object:Gem::Version
|
80
69
|
version: '0'
|
81
70
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
83
|
-
signing_key:
|
71
|
+
rubygems_version: 3.5.22
|
72
|
+
signing_key:
|
84
73
|
specification_version: 4
|
85
74
|
summary: Wobbly is an easy to use token type date parser in Ruby
|
86
75
|
test_files: []
|