stamp 0.3.0 → 0.4.0
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.
- data/Gemfile.lock +1 -1
- data/README.md +4 -3
- data/features/stamp.feature +1 -0
- data/lib/stamp/translator.rb +7 -1
- data/lib/stamp/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -46,7 +46,7 @@ date.stamp("1st of Jan") #=> "9th of Jun"
|
|
46
46
|
### Times
|
47
47
|
|
48
48
|
`Time#stamp` supports the same kinds of examples as `Date`, but also formats
|
49
|
-
hours, minutes, and seconds when it sees colon-separated values
|
49
|
+
hours, minutes, and seconds when it sees colon-separated values.
|
50
50
|
|
51
51
|
```ruby
|
52
52
|
time = Time.utc(2011, 6, 9, 20, 52, 30)
|
@@ -55,13 +55,15 @@ time.stamp("01:00:00 AM") #=> "08:52:30 PM"
|
|
55
55
|
time.stamp("23:59") #=> "20:52"
|
56
56
|
time.stamp("23:59:59") #=> "20:52:30"
|
57
57
|
time.stamp("Jan 1 at 01:00 AM") #=> "Jun 9 at 08:52 PM"
|
58
|
+
time.stamp("23:59 UTC") #=> "20:52 PST"
|
58
59
|
```
|
59
60
|
|
60
61
|
## Features
|
61
62
|
|
62
63
|
* Abbreviated and full names of months and weekdays are recognized.
|
63
64
|
* Days with or without a leading zero work instinctively.
|
64
|
-
*
|
65
|
+
* Standard time zone abbreviations are recognized; e.g. "UTC", "PST", "EST".
|
66
|
+
* Include any extraneous text you'd like; e.g. "DOB:".
|
65
67
|
|
66
68
|
### Disambiguation by value
|
67
69
|
|
@@ -96,7 +98,6 @@ Time.now.to_s(:military) #=> "15:35"
|
|
96
98
|
|
97
99
|
### Limitations
|
98
100
|
|
99
|
-
* Time zone support hasn't been implemented. Patches welcome!
|
100
101
|
* DateTime should inherit stamp behavior from Date, but it hasn't been thoroughly tested. Patches welcome!
|
101
102
|
|
102
103
|
### Advanced Usage
|
data/features/stamp.feature
CHANGED
data/lib/stamp/translator.rb
CHANGED
@@ -5,6 +5,9 @@ module Stamp
|
|
5
5
|
DAYNAMES_REGEXP = /^(#{Date::DAYNAMES.join('|')})$/i
|
6
6
|
ABBR_DAYNAMES_REGEXP = /^(#{Date::ABBR_DAYNAMES.join('|')})$/i
|
7
7
|
|
8
|
+
# Full list of time zone abbreviations from http://en.wikipedia.org/wiki/List_of_time_zone_abbreviations
|
9
|
+
TIMEZONE_REGEXP = /^(ACDT|ACST|ACT|ADT|AEDT|AEST|AFT|AKDT|AKST|AMST|AMT|ART|AST|AST|AST|AST|AWDT|AWST|AZOST|AZT|BDT|BIOT|BIT|BOT|BRT|BST|BST|BTT|CAT|CCT|CDT|CDT|CEDT|CEST|CET|CHADT|CHAST|CHOT|ChST|CHUT|CIST|CIT|CKT|CLST|CLT|COST|COT|CST|CST|CST|CST|CST|CT|CVT|CWST|CXT|DAVT|DDUT|DFT|EASST|EAST|EAT|ECT|ECT|EDT|EEDT|EEST|EET|EGST|EGT|EIT|EST|EST|FET|FJT|FKST|FKT|FNT|GALT|GAMT|GET|GFT|GILT|GIT|GMT|GST|GST|GYT|HADT|HAEC|HAST|HKT|HMT|HOVT|HST|ICT|IDT|IOT|IRDT|IRKT|IRST|IST|IST|IST|JST|KGT|KOST|KRAT|KST|LHST|LHST|LINT|MAGT|MART|MAWT|MDT|MET|MEST|MHT|MIST|MIT|MMT|MSK|MST|MST|MST|MUT|MVT|MYT|NCT|NDT|NFT|NPT|NST|NT|NUT|NZDT|NZST|OMST|ORAT|PDT|PET|PETT|PGT|PHOT|PHT|PKT|PMDT|PMST|PONT|PST|PST|RET|ROTT|SAKT|SAMT|SAST|SBT|SCT|SGT|SLT|SRT|SST|SST|SYOT|TAHT|THA|TFT|TJT|TKT|TLT|TMT|TOT|TVT|UCT|ULAT|UTC|UYST|UYT|UZT|VET|VLAT|VOLT|VOST|VUT|WAKT|WAST|WAT|WEDT|WEST|WET|WST|YAKT|YEKT)$/
|
10
|
+
|
8
11
|
ONE_DIGIT_REGEXP = /^\d{1}$/
|
9
12
|
TWO_DIGIT_REGEXP = /^\d{2}$/
|
10
13
|
FOUR_DIGIT_REGEXP = /^\d{4}$/
|
@@ -148,6 +151,9 @@ module Stamp
|
|
148
151
|
when ABBR_DAYNAMES_REGEXP
|
149
152
|
'%a'
|
150
153
|
|
154
|
+
when TIMEZONE_REGEXP
|
155
|
+
'%Z'
|
156
|
+
|
151
157
|
when FOUR_DIGIT_REGEXP
|
152
158
|
'%Y'
|
153
159
|
|
@@ -176,4 +182,4 @@ module Stamp
|
|
176
182
|
end
|
177
183
|
|
178
184
|
end
|
179
|
-
end
|
185
|
+
end
|
data/lib/stamp/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stamp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-06 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Format dates and times based on human-friendly examples, not arcane strftime
|
15
15
|
directives.
|
@@ -49,7 +49,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
49
49
|
version: '0'
|
50
50
|
segments:
|
51
51
|
- 0
|
52
|
-
hash:
|
52
|
+
hash: 2023252387998863659
|
53
53
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
54
|
none: false
|
55
55
|
requirements:
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
version: '0'
|
59
59
|
segments:
|
60
60
|
- 0
|
61
|
-
hash:
|
61
|
+
hash: 2023252387998863659
|
62
62
|
requirements: []
|
63
63
|
rubyforge_project:
|
64
64
|
rubygems_version: 1.8.23
|