local_time 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 508731c2caa5d18aece1d61aa62fea93a39eaeeb
4
- data.tar.gz: e0f58da60da529a8ad4daa7304eb696a9e3ff963
3
+ metadata.gz: e386d2a684296b0e7489cc13bee76a7df4495474
4
+ data.tar.gz: 1167fdacc381765bc7ef5cf31499e9c46c23083c
5
5
  SHA512:
6
- metadata.gz: 82c365b1b4c213fbfeb4a7e897472fd4ce993d0ae23fcda3ac41b5288b63e9e5c821a9509b1acca8f46fd37106609be64301324347cba4ffb1bddcbb4688f660
7
- data.tar.gz: 5751bf6dd16e8f0de883ce99772c6314a996c3411483c2909e9dd46d79c0b18a4efbb527ac1e2e43cf872fa67e8651419e250381c4a0303552e62061c37dd01a
6
+ metadata.gz: f66918a56f5cb8c3be57c99537a1d054f7a10a6bedf2a309c320da407025e1f2b9b1f3410c60e5f532e3ffacc378bf65183b705253bdbd8d08e7023c741483c2
7
+ data.tar.gz: 954b8526c0846718f9bfe0e81eb1660a02399cf76cf9e5cb056bdc492e38abd0c13feb2c22ba09d93c6969457354f25c1cbf1752e34c3b3888f2b6362afd2221
data/README.md CHANGED
@@ -127,6 +127,11 @@ The included JavaScript does not depend on any frameworks or libraries, and list
127
127
 
128
128
  #### Version History
129
129
 
130
+ **1.0.3**
131
+
132
+ * Improve `%Z` time zone parsing
133
+ * Use [Blade](https://github.com/javan/blade) runner for JavaScript tests
134
+
130
135
  **1.0.2** (February 3, 2015)
131
136
 
132
137
  * Fix displaying future relative dates [Cezary Baginski]
@@ -156,3 +161,9 @@ The included JavaScript does not depend on any frameworks or libraries, and list
156
161
  **0.1.0** (November 29, 2013)
157
162
 
158
163
  * Initial release.
164
+
165
+ ---
166
+
167
+ [![Build Status](https://travis-ci.org/basecamp/local_time.svg?branch=master)](https://travis-ci.org/basecamp/local_time)
168
+
169
+ [![Sauce Test Status](https://saucelabs.com/browser-matrix/basecamp_local_time.svg)](https://saucelabs.com/u/basecamp_local_time)
@@ -21,6 +21,25 @@ months = "January February March April May June July August September October
21
21
 
22
22
  pad = (num) -> ('0' + num).slice -2
23
23
 
24
+ parseTimeZone = (time) ->
25
+ string = time.toString()
26
+ # Sun Aug 30 2015 10:22:57 GMT-0400 (NAME)
27
+ if name = string.match(/\(([\w\s]+)\)$/)?[1]
28
+ if /\s/.test(name)
29
+ # Sun Aug 30 2015 10:22:57 GMT-0400 (Eastern Daylight Time)
30
+ name.match(/\b(\w)/g).join("")
31
+ else
32
+ # Sun Aug 30 2015 10:22:57 GMT-0400 (EDT)
33
+ name
34
+ # Sun Aug 30 10:22:57 EDT 2015
35
+ else if name = string.match(/(\w{3,4})\s\d{4}$/)?[1]
36
+ name
37
+ # "Sun Aug 30 10:22:57 UTC-0400 2015"
38
+ else if name = string.match(/(UTC[\+\-]\d+)/)?[1]
39
+ name
40
+ else
41
+ ""
42
+
24
43
  strftime = (time, formatString) ->
25
44
  day = time.getDay()
26
45
  date = time.getDate()
@@ -51,7 +70,7 @@ strftime = (time, formatString) ->
51
70
  when 'w' then day
52
71
  when 'y' then pad year % 100
53
72
  when 'Y' then year
54
- when 'Z' then time.toString().match(/\((\w+)\)$/)?[1] ? ''
73
+ when 'Z' then parseTimeZone(time)
55
74
 
56
75
 
57
76
  class CalendarDate
@@ -0,0 +1,8 @@
1
+ <time id="one" data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="2013-11-12T12:13:00Z"></time>
2
+ <time id="two" data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="2013-01-02T02:04:00Z"></time>
3
+ <time id="past" data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="1805-05-15T01:01:00Z"></time>
4
+ <time id="future" data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="3333-02-14T23:55:00Z"></time>
5
+
6
+ <time id="date" data-format="%B %e, %Y" data-local="time" datetime="2013-11-12T12:13:00Z"></time>
7
+
8
+ <time id="ago"></time>
@@ -44,5 +44,4 @@ for day in [0..30] by 6
44
44
  run()
45
45
 
46
46
  text = getText el
47
- ok /^\w{3,4}$/.test(text), "#{text} doesn't look like a timezone"
48
-
47
+ ok /^(\w{3,4}|UTC[\+\-]\d+)$/.test(text), "'#{text}' doesn't look like a timezone. System date: '#{new Date}'"
@@ -1,7 +1,5 @@
1
- #= require vendor/qunit
2
- #= require vendor/moment
3
- #= require vendor/sinon-timers
4
- #= require local_time
1
+ #= require moment
2
+ #= require sinon-timers
5
3
 
6
4
  #= require_self
7
5
  #= require_directory .
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Javan Makhmali
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-03 00:00:00.000000000 Z
12
+ date: 2015-08-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coffee-rails
@@ -53,6 +53,34 @@ dependencies:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: blade
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: 0.3.0
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: 0.3.0
70
+ - !ruby/object:Gem::Dependency
71
+ name: blade-sauce_labs_plugin
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: 0.3.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: 0.3.0
56
84
  description:
57
85
  email: javan@basecamp.com
58
86
  executables: []
@@ -65,19 +93,15 @@ files:
65
93
  - app/helpers/local_time_helper.rb
66
94
  - lib/local_time.rb
67
95
  - test/helpers/local_time_helper_test.rb
68
- - test/javascripts/local_time/index.js.coffee
69
- - test/javascripts/local_time/local_time_test.js.coffee
70
- - test/javascripts/local_time/page_events_test.js.coffee
71
- - test/javascripts/local_time/public_api_test.js.coffee
72
- - test/javascripts/local_time/relative_date_test.js.coffee
73
- - test/javascripts/local_time/strftime_test.js.coffee
74
- - test/javascripts/local_time/time_ago_test.js.coffee
75
- - test/javascripts/runner/config.ru
76
- - test/javascripts/runner/index.html
96
+ - test/javascripts/fixtures/body.html
97
+ - test/javascripts/src/local_time_test.js.coffee
98
+ - test/javascripts/src/page_events_test.js.coffee
99
+ - test/javascripts/src/public_api_test.js.coffee
100
+ - test/javascripts/src/relative_date_test.js.coffee
101
+ - test/javascripts/src/strftime_test.js.coffee
102
+ - test/javascripts/src/test.js.coffee
103
+ - test/javascripts/src/time_ago_test.js.coffee
77
104
  - test/javascripts/vendor/moment.js
78
- - test/javascripts/vendor/qunit.css
79
- - test/javascripts/vendor/qunit.js
80
- - test/javascripts/vendor/run-qunit.coffee
81
105
  - test/javascripts/vendor/sinon-timers.js
82
106
  homepage:
83
107
  licenses:
@@ -99,23 +123,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
123
  version: '0'
100
124
  requirements: []
101
125
  rubyforge_project:
102
- rubygems_version: 2.2.2
126
+ rubygems_version: 2.4.6
103
127
  signing_key:
104
128
  specification_version: 4
105
129
  summary: Rails engine for cache-friendly, client-side local time
106
130
  test_files:
107
131
  - test/helpers/local_time_helper_test.rb
108
- - test/javascripts/local_time/index.js.coffee
109
- - test/javascripts/local_time/local_time_test.js.coffee
110
- - test/javascripts/local_time/page_events_test.js.coffee
111
- - test/javascripts/local_time/public_api_test.js.coffee
112
- - test/javascripts/local_time/relative_date_test.js.coffee
113
- - test/javascripts/local_time/strftime_test.js.coffee
114
- - test/javascripts/local_time/time_ago_test.js.coffee
115
- - test/javascripts/runner/config.ru
116
- - test/javascripts/runner/index.html
132
+ - test/javascripts/fixtures/body.html
133
+ - test/javascripts/src/local_time_test.js.coffee
134
+ - test/javascripts/src/page_events_test.js.coffee
135
+ - test/javascripts/src/public_api_test.js.coffee
136
+ - test/javascripts/src/relative_date_test.js.coffee
137
+ - test/javascripts/src/strftime_test.js.coffee
138
+ - test/javascripts/src/test.js.coffee
139
+ - test/javascripts/src/time_ago_test.js.coffee
117
140
  - test/javascripts/vendor/moment.js
118
- - test/javascripts/vendor/qunit.css
119
- - test/javascripts/vendor/qunit.js
120
- - test/javascripts/vendor/run-qunit.coffee
121
141
  - test/javascripts/vendor/sinon-timers.js
@@ -1,19 +0,0 @@
1
- require 'sprockets'
2
- require 'coffee-rails'
3
-
4
- Root = File.expand_path("../../../..", __FILE__)
5
-
6
- Assets = Sprockets::Environment.new(Root) do |env|
7
- env.append_path "app/assets/javascripts"
8
- env.append_path "test/javascripts"
9
- end
10
-
11
- map "/css" do
12
- run Assets
13
- end
14
-
15
- map "/js" do
16
- run Assets
17
- end
18
-
19
- map("/") { run Rack::File.new("#{Root}/test/javascripts/runner") }
@@ -1,20 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <link rel="stylesheet" href="/css/vendor/qunit.css">
6
- <script type="text/javascript" src="/js/local_time/index.js"></script>
7
- </head>
8
- <body>
9
- <div id="qunit"></div>
10
- <div id="qunit-fixture"></div>
11
-
12
- <time id="one" data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="2013-11-12T12:13:00Z"></time>
13
- <time id="two" data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="2013-01-02T02:04:00Z"></time>
14
- <time id="past" data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="1805-05-15T01:01:00Z"></time>
15
- <time id="future" data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="3333-02-14T23:55:00Z"></time>
16
-
17
- <time id="date" data-format="%B %e, %Y" data-local="time" datetime="2013-11-12T12:13:00Z"></time>
18
-
19
- <time id="ago"></time>
20
- </html>
@@ -1,244 +0,0 @@
1
- /**
2
- * QUnit v1.12.0 - A JavaScript Unit Testing Framework
3
- *
4
- * http://qunitjs.com
5
- *
6
- * Copyright 2012 jQuery Foundation and other contributors
7
- * Released under the MIT license.
8
- * http://jquery.org/license
9
- */
10
-
11
- /** Font Family and Sizes */
12
-
13
- #qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
14
- font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
15
- }
16
-
17
- #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
18
- #qunit-tests { font-size: smaller; }
19
-
20
-
21
- /** Resets */
22
-
23
- #qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
24
- margin: 0;
25
- padding: 0;
26
- }
27
-
28
-
29
- /** Header */
30
-
31
- #qunit-header {
32
- padding: 0.5em 0 0.5em 1em;
33
-
34
- color: #8699a4;
35
- background-color: #0d3349;
36
-
37
- font-size: 1.5em;
38
- line-height: 1em;
39
- font-weight: normal;
40
-
41
- border-radius: 5px 5px 0 0;
42
- -moz-border-radius: 5px 5px 0 0;
43
- -webkit-border-top-right-radius: 5px;
44
- -webkit-border-top-left-radius: 5px;
45
- }
46
-
47
- #qunit-header a {
48
- text-decoration: none;
49
- color: #c2ccd1;
50
- }
51
-
52
- #qunit-header a:hover,
53
- #qunit-header a:focus {
54
- color: #fff;
55
- }
56
-
57
- #qunit-testrunner-toolbar label {
58
- display: inline-block;
59
- padding: 0 .5em 0 .1em;
60
- }
61
-
62
- #qunit-banner {
63
- height: 5px;
64
- }
65
-
66
- #qunit-testrunner-toolbar {
67
- padding: 0.5em 0 0.5em 2em;
68
- color: #5E740B;
69
- background-color: #eee;
70
- overflow: hidden;
71
- }
72
-
73
- #qunit-userAgent {
74
- padding: 0.5em 0 0.5em 2.5em;
75
- background-color: #2b81af;
76
- color: #fff;
77
- text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
78
- }
79
-
80
- #qunit-modulefilter-container {
81
- float: right;
82
- }
83
-
84
- /** Tests: Pass/Fail */
85
-
86
- #qunit-tests {
87
- list-style-position: inside;
88
- }
89
-
90
- #qunit-tests li {
91
- padding: 0.4em 0.5em 0.4em 2.5em;
92
- border-bottom: 1px solid #fff;
93
- list-style-position: inside;
94
- }
95
-
96
- #qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
97
- display: none;
98
- }
99
-
100
- #qunit-tests li strong {
101
- cursor: pointer;
102
- }
103
-
104
- #qunit-tests li a {
105
- padding: 0.5em;
106
- color: #c2ccd1;
107
- text-decoration: none;
108
- }
109
- #qunit-tests li a:hover,
110
- #qunit-tests li a:focus {
111
- color: #000;
112
- }
113
-
114
- #qunit-tests li .runtime {
115
- float: right;
116
- font-size: smaller;
117
- }
118
-
119
- .qunit-assert-list {
120
- margin-top: 0.5em;
121
- padding: 0.5em;
122
-
123
- background-color: #fff;
124
-
125
- border-radius: 5px;
126
- -moz-border-radius: 5px;
127
- -webkit-border-radius: 5px;
128
- }
129
-
130
- .qunit-collapsed {
131
- display: none;
132
- }
133
-
134
- #qunit-tests table {
135
- border-collapse: collapse;
136
- margin-top: .2em;
137
- }
138
-
139
- #qunit-tests th {
140
- text-align: right;
141
- vertical-align: top;
142
- padding: 0 .5em 0 0;
143
- }
144
-
145
- #qunit-tests td {
146
- vertical-align: top;
147
- }
148
-
149
- #qunit-tests pre {
150
- margin: 0;
151
- white-space: pre-wrap;
152
- word-wrap: break-word;
153
- }
154
-
155
- #qunit-tests del {
156
- background-color: #e0f2be;
157
- color: #374e0c;
158
- text-decoration: none;
159
- }
160
-
161
- #qunit-tests ins {
162
- background-color: #ffcaca;
163
- color: #500;
164
- text-decoration: none;
165
- }
166
-
167
- /*** Test Counts */
168
-
169
- #qunit-tests b.counts { color: black; }
170
- #qunit-tests b.passed { color: #5E740B; }
171
- #qunit-tests b.failed { color: #710909; }
172
-
173
- #qunit-tests li li {
174
- padding: 5px;
175
- background-color: #fff;
176
- border-bottom: none;
177
- list-style-position: inside;
178
- }
179
-
180
- /*** Passing Styles */
181
-
182
- #qunit-tests li li.pass {
183
- color: #3c510c;
184
- background-color: #fff;
185
- border-left: 10px solid #C6E746;
186
- }
187
-
188
- #qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
189
- #qunit-tests .pass .test-name { color: #366097; }
190
-
191
- #qunit-tests .pass .test-actual,
192
- #qunit-tests .pass .test-expected { color: #999999; }
193
-
194
- #qunit-banner.qunit-pass { background-color: #C6E746; }
195
-
196
- /*** Failing Styles */
197
-
198
- #qunit-tests li li.fail {
199
- color: #710909;
200
- background-color: #fff;
201
- border-left: 10px solid #EE5757;
202
- white-space: pre;
203
- }
204
-
205
- #qunit-tests > li:last-child {
206
- border-radius: 0 0 5px 5px;
207
- -moz-border-radius: 0 0 5px 5px;
208
- -webkit-border-bottom-right-radius: 5px;
209
- -webkit-border-bottom-left-radius: 5px;
210
- }
211
-
212
- #qunit-tests .fail { color: #000000; background-color: #EE5757; }
213
- #qunit-tests .fail .test-name,
214
- #qunit-tests .fail .module-name { color: #000000; }
215
-
216
- #qunit-tests .fail .test-actual { color: #EE5757; }
217
- #qunit-tests .fail .test-expected { color: green; }
218
-
219
- #qunit-banner.qunit-fail { background-color: #EE5757; }
220
-
221
-
222
- /** Result */
223
-
224
- #qunit-testresult {
225
- padding: 0.5em 0.5em 0.5em 2.5em;
226
-
227
- color: #2b81af;
228
- background-color: #D2E0E6;
229
-
230
- border-bottom: 1px solid white;
231
- }
232
- #qunit-testresult .module-name {
233
- font-weight: bold;
234
- }
235
-
236
- /** Fixture */
237
-
238
- #qunit-fixture {
239
- position: absolute;
240
- top: -10000px;
241
- left: -10000px;
242
- width: 1000px;
243
- height: 1000px;
244
- }