timing 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +118 -1
- data/Rakefile +1 -0
- data/lib/timing/time_in_zone.rb +6 -1
- data/lib/timing/version.rb +1 -1
- data/lib/timing/zone_offset.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9d3f014400da6b44b2afaf3d8f15af729863b24
|
4
|
+
data.tar.gz: a735431bb16759291c7eb06e9ae366365f4435d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f67d4efec377bf8fc2f667ee031238f530bc82a1093068a23ce4f4982224b784f9b7c9dbcb9c3bccdda3395d2b99f8067f9b560794501485136ee47ac5f65bc9
|
7
|
+
data.tar.gz: f2ac4a9ba491b548cdb5ea4c8a6694a3ffead179d623849e9836ec9580850675eeb10b6d11240509381950fede3c71754dc3f35b1b9be631336f09b85e711208
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -26,8 +26,125 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
## Usage
|
28
28
|
|
29
|
-
|
29
|
+
#### TimeInZone
|
30
30
|
|
31
|
+
Acts like Time with specific utc offset.
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
Time.now # => 2015-10-19 22:10:47 -0300
|
35
|
+
Timing::TimeInZone.now # => 2015-10-19 22:10:47 -0300
|
36
|
+
Timing::TimeInZone.now '-0400' # => 2015-10-19 21:10:47 -0400
|
37
|
+
|
38
|
+
Timing::TimeInZone.at 1445303855 # => 2015-10-19 22:17:35 -0300
|
39
|
+
Timing::TimeInZone.at 1445303855, '+0200' # => 2015-10-20 03:17:35 +0200
|
40
|
+
|
41
|
+
Timing::TimeInZone.now # => 2015-10-19 22:22:52 -0300
|
42
|
+
Timing::TimeInZone.now.to_zone('-0100') # => 2015-10-20 00:22:52 -0100
|
43
|
+
|
44
|
+
time = Timing::TimeInZone.now '+0200' # => 2015-10-20 03:36:14 +0200
|
45
|
+
time.zone_offset = '-0100'
|
46
|
+
time # => 2015-10-20 00:36:14 -0100
|
47
|
+
|
48
|
+
time = Timing::TimeInZone.now '-0700' # => 2015-10-19 18:29:29 -0700
|
49
|
+
time + 3600 # => 2015-10-19 19:29:29 -0700
|
50
|
+
Timing::TimeInZone.now - time # => 250.85015296936035
|
51
|
+
time.to_time # => 2015-10-19 22:29:29 -0300
|
52
|
+
```
|
53
|
+
|
54
|
+
|
55
|
+
#### Interval
|
56
|
+
|
57
|
+
Seconds wrapper with helper methods.
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
Timing::Interval.new 10 # => 10s (10.0)
|
61
|
+
|
62
|
+
Timing::Interval.seconds(20) # => 20s (20.0)
|
63
|
+
Timing::Interval.minutes(15) # => 15m (900.0)
|
64
|
+
Timing::Interval.hours(7) # => 7h (25200.0)
|
65
|
+
Timing::Interval.days(5) # => 5d (432000.0)
|
66
|
+
Timing::Interval.weeks(2) # => 2w (1209600.0)
|
67
|
+
|
68
|
+
Timing::Interval.parse('20s') # => 20s (20.0)
|
69
|
+
Timing::Interval.parse('15m') # => 15m (900.0)
|
70
|
+
Timing::Interval.parse('7h') # => 7h (25200.0)
|
71
|
+
Timing::Interval.parse('5d') # => 5d (432000.0)
|
72
|
+
Timing::Interval.parse('2w') # => 2w (1209600.0)
|
73
|
+
|
74
|
+
interval = Timing::Interval.weeks(1)
|
75
|
+
interval.to_seconds # => 604800.0
|
76
|
+
interval.to_minutes # => 10080.0
|
77
|
+
interval.to_hours # => 168.0
|
78
|
+
interval.to_days # => 7.0
|
79
|
+
interval.to_weeks # => 1.0
|
80
|
+
```
|
81
|
+
|
82
|
+
|
83
|
+
#### NaturalTimeLanguage
|
84
|
+
|
85
|
+
Natural language to specify times.
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
Timing::NaturalTimeLanguage.parse 'now'
|
89
|
+
```
|
90
|
+
|
91
|
+
Named moments
|
92
|
+
- now
|
93
|
+
- Now -0500
|
94
|
+
- today
|
95
|
+
- today +0000
|
96
|
+
- Today -0600
|
97
|
+
- yesterday -0400
|
98
|
+
- tomorrow -0300
|
99
|
+
|
100
|
+
Last/Next day name
|
101
|
+
- last Monday +0200
|
102
|
+
- last fri +0100
|
103
|
+
- next tuesday +0000
|
104
|
+
- next sat -0100
|
105
|
+
|
106
|
+
Date (at 00:00:00)
|
107
|
+
- 6 April
|
108
|
+
- 14 Jul 2010 +0400
|
109
|
+
- 2015-09-03
|
110
|
+
- 2015-06-20 -0800
|
111
|
+
|
112
|
+
Beginning/End of interval
|
113
|
+
- Beginning of month
|
114
|
+
- end of year +0700
|
115
|
+
- beginning of week
|
116
|
+
- End of Day -0100
|
117
|
+
- end of hour +0400
|
118
|
+
|
119
|
+
Time ago (now - interval)
|
120
|
+
- 1 minute ago
|
121
|
+
- 3 hours ago -0500
|
122
|
+
- 5 days ago -0100
|
123
|
+
- 4 weeks ago +0100
|
124
|
+
- 10 months ago +0330
|
125
|
+
- 7 years ago -0700
|
126
|
+
|
127
|
+
Date at time
|
128
|
+
- today at 15:40
|
129
|
+
- last sunday at 08:43:21 -0300
|
130
|
+
- yesterday at beginning
|
131
|
+
- next friday at beginning -0100
|
132
|
+
- beginning of year at end
|
133
|
+
- 14 May 2011 at end -0400
|
134
|
+
- 25 Nov at 13:25
|
135
|
+
- 2001-07-14 at 18:41
|
136
|
+
- 2012-08-17 14:35:20
|
137
|
+
- 1980-04-21T08:15:03-0500
|
138
|
+
|
139
|
+
Before/After moment
|
140
|
+
- 15 minutes from now
|
141
|
+
- 3 days before yesterday
|
142
|
+
- 1 month from today
|
143
|
+
- 1 week from last monday at 08:30 -0400
|
144
|
+
- 5 days before next friday at end
|
145
|
+
- 1 month before beginning of month
|
146
|
+
- 1 year before 9 Sep +0300
|
147
|
+
- 2 years from 2001-05-21T12:30:40 -0500
|
31
148
|
|
32
149
|
## Contributing
|
33
150
|
|
data/Rakefile
CHANGED
data/lib/timing/time_in_zone.rb
CHANGED
@@ -58,7 +58,12 @@ module Timing
|
|
58
58
|
alias_method :inspect, :to_s
|
59
59
|
|
60
60
|
def strftime(format)
|
61
|
-
|
61
|
+
sanitized_format = format.gsub('%Z', '')
|
62
|
+
.gsub('%z', zone_offset.to_s)
|
63
|
+
.gsub('%:z', zone_offset.to_s(':'))
|
64
|
+
.gsub('%::z', "#{zone_offset.to_s(':')}:00")
|
65
|
+
|
66
|
+
time_with_offset.strftime sanitized_format
|
62
67
|
end
|
63
68
|
|
64
69
|
def iso8601
|
data/lib/timing/version.rb
CHANGED
data/lib/timing/zone_offset.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Naiman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: treetop
|
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
170
|
rubyforge_project:
|
171
|
-
rubygems_version: 2.4.
|
171
|
+
rubygems_version: 2.4.8
|
172
172
|
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Time utils
|