local_time 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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 508731c2caa5d18aece1d61aa62fea93a39eaeeb
|
4
|
+
data.tar.gz: e0f58da60da529a8ad4daa7304eb696a9e3ff963
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82c365b1b4c213fbfeb4a7e897472fd4ce993d0ae23fcda3ac41b5288b63e9e5c821a9509b1acca8f46fd37106609be64301324347cba4ffb1bddcbb4688f660
|
7
|
+
data.tar.gz: 5751bf6dd16e8f0de883ce99772c6314a996c3411483c2909e9dd46d79c0b18a4efbb527ac1e2e43cf872fa67e8651419e250381c4a0303552e62061c37dd01a
|
data/MIT-LICENSE
CHANGED
data/README.md
CHANGED
@@ -94,7 +94,7 @@ Preset time and date formats that vary with age. The available types are `date`,
|
|
94
94
|
|
95
95
|
**Available `:type` options**
|
96
96
|
|
97
|
-
* `date`
|
97
|
+
* `date` Includes the year unless it's current. "Apr 11" or "Apr 11, 2013"
|
98
98
|
* `time-ago` See above. `local_time_ago` calls `local_relative_time` with this `:type` option.
|
99
99
|
* `time-or-date` Displays the time if it occurs today or the date if not. "3:26pm" or "Apr 11"
|
100
100
|
* `weekday` Displays "Today", "Yesterday", or the weekday (e.g. Wednesday) if the time is within a week of today.
|
@@ -127,6 +127,10 @@ The included JavaScript does not depend on any frameworks or libraries, and list
|
|
127
127
|
|
128
128
|
#### Version History
|
129
129
|
|
130
|
+
**1.0.2** (February 3, 2015)
|
131
|
+
|
132
|
+
* Fix displaying future relative dates [Cezary Baginski]
|
133
|
+
|
130
134
|
**1.0.1** (December 3, 2014)
|
131
135
|
|
132
136
|
* Added `weekday-or-date` option [Chew Choon Keat]
|
@@ -141,16 +141,13 @@ class RelativeTime
|
|
141
141
|
null
|
142
142
|
|
143
143
|
relativeWeekday: ->
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
"yesterday"
|
152
|
-
else
|
153
|
-
strftime @date, "%A"
|
144
|
+
switch @calendarDate.daysPassed()
|
145
|
+
when 0
|
146
|
+
"today"
|
147
|
+
when 1
|
148
|
+
"yesterday"
|
149
|
+
when 2,3,4,5,6
|
150
|
+
strftime @date, "%A"
|
154
151
|
|
155
152
|
formatDate: ->
|
156
153
|
format = "%b %e"
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require_relative '../../app/helpers/local_time_helper'
|
2
2
|
require 'active_support/all'
|
3
3
|
require 'action_view'
|
4
|
+
require 'rails-dom-testing'
|
4
5
|
|
5
6
|
require 'minitest/autorun'
|
6
7
|
begin
|
@@ -15,6 +16,8 @@ I18n.enforce_available_locales = false
|
|
15
16
|
|
16
17
|
class LocalTimeHelperTest < TestCase
|
17
18
|
include ActionView::Helpers::DateHelper, ActionView::Helpers::TagHelper
|
19
|
+
include Rails::Dom::Testing::Assertions::DomAssertions
|
20
|
+
|
18
21
|
include LocalTimeHelper
|
19
22
|
|
20
23
|
def setup
|
@@ -51,93 +54,93 @@ class LocalTimeHelperTest < TestCase
|
|
51
54
|
|
52
55
|
def test_local_time
|
53
56
|
expected = %Q(<time data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="#{@time_js}">November 21, 2013 6:00am</time>)
|
54
|
-
|
57
|
+
assert_dom_equal expected, local_time(@time)
|
55
58
|
end
|
56
59
|
|
57
60
|
def test_local_time_with_format
|
58
61
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}">Nov 21</time>)
|
59
|
-
|
62
|
+
assert_dom_equal expected, local_time(@time, format: '%b %e')
|
60
63
|
end
|
61
64
|
|
62
65
|
def test_local_time_with_format_as_string
|
63
66
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}">Nov 21</time>)
|
64
|
-
|
67
|
+
assert_dom_equal expected, local_time(@time, '%b %e')
|
65
68
|
end
|
66
69
|
|
67
70
|
def test_local_time_with_i18n_format
|
68
71
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}">Nov 21</time>)
|
69
|
-
|
72
|
+
assert_dom_equal expected, local_time(@time, format: :simple_time)
|
70
73
|
end
|
71
74
|
|
72
75
|
def test_local_time_with_date_formats_format
|
73
76
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}">Nov 21</time>)
|
74
|
-
|
77
|
+
assert_dom_equal expected, local_time(@time, format: :time_formats_simple_time)
|
75
78
|
end
|
76
79
|
|
77
80
|
def test_local_time_with_missing_i18n_and_date_formats_format
|
78
81
|
expected = %Q(<time data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="#{@time_js}">November 21, 2013 6:00am</time>)
|
79
|
-
|
82
|
+
assert_dom_equal expected, local_time(@time, format: :missing_format)
|
80
83
|
end
|
81
84
|
|
82
85
|
def test_local_time_with_date_formats_proc_format
|
83
86
|
Time::DATE_FORMATS[:proc] = proc { |time| "nope" }
|
84
87
|
expected = %Q(<time data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="#{@time_js}">November 21, 2013 6:00am</time>)
|
85
|
-
|
88
|
+
assert_dom_equal expected, local_time(@time, format: :proc)
|
86
89
|
end
|
87
90
|
|
88
91
|
def test_local_time_with_options
|
89
92
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}" style="display:none">Nov 21</time>)
|
90
|
-
|
93
|
+
assert_dom_equal expected, local_time(@time, format: '%b %e', style: 'display:none')
|
91
94
|
end
|
92
95
|
|
93
96
|
def test_local_date
|
94
97
|
expected = %Q(<time data-format="%B %e, %Y" data-local="time" datetime="#{@time_js}">November 21, 2013</time>)
|
95
|
-
|
96
|
-
|
98
|
+
assert_dom_equal expected, local_date(@time)
|
99
|
+
assert_dom_equal expected, local_date(@time.to_date)
|
97
100
|
end
|
98
101
|
|
99
102
|
def test_local_date_with_format
|
100
103
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}">Nov 21</time>)
|
101
|
-
|
104
|
+
assert_dom_equal expected, local_date(@time.to_date, format: '%b %e')
|
102
105
|
end
|
103
106
|
|
104
107
|
def test_local_date_with_format_as_string
|
105
108
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}">Nov 21</time>)
|
106
|
-
|
109
|
+
assert_dom_equal expected, local_date(@time.to_date, '%b %e')
|
107
110
|
end
|
108
111
|
|
109
112
|
def test_local_date_with_i18n_format
|
110
113
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}">Nov 21</time>)
|
111
|
-
|
114
|
+
assert_dom_equal expected, local_date(@time.to_date, format: :simple_date)
|
112
115
|
end
|
113
116
|
|
114
117
|
def test_local_date_with_date_formats_format
|
115
118
|
expected = %Q(<time data-format="%b %e" data-local="time" datetime="#{@time_js}">Nov 21</time>)
|
116
|
-
|
119
|
+
assert_dom_equal expected, local_date(@time.to_date, format: :date_formats_simple_date)
|
117
120
|
end
|
118
121
|
|
119
122
|
def test_local_date_with_missing_i18n_and_date_formats_format
|
120
123
|
expected = %Q(<time data-format="%B %e, %Y %l:%M%P" data-local="time" datetime="#{@time_js}">November 21, 2013 6:00am</time>)
|
121
|
-
|
124
|
+
assert_dom_equal expected, local_date(@time.to_date, format: :missing_date_format)
|
122
125
|
end
|
123
126
|
|
124
127
|
def test_local_time_ago
|
125
128
|
expected = %Q(<time data-local="time-ago" datetime="#{@time_js}">November 21, 2013 6:00am</time>)
|
126
|
-
|
129
|
+
assert_dom_equal expected, local_time_ago(@time)
|
127
130
|
end
|
128
131
|
|
129
132
|
def test_local_time_ago_with_options
|
130
133
|
expected = %Q(<time class="date-time" data-local="time-ago" datetime="#{@time_js}">November 21, 2013 6:00am</time>)
|
131
|
-
|
134
|
+
assert_dom_equal expected, local_time_ago(@time, class: "date-time")
|
132
135
|
end
|
133
136
|
|
134
137
|
def test_relative_time
|
135
138
|
expected = %Q(<time data-local="time-or-date" datetime="#{@time_js}">November 21, 2013 6:00am</time>)
|
136
|
-
|
139
|
+
assert_dom_equal expected, local_relative_time(@time, type: "time-or-date")
|
137
140
|
end
|
138
141
|
|
139
142
|
def test_local_time_ago_with_type_as_string
|
140
143
|
expected = %Q(<time data-local="time-or-date" datetime="#{@time_js}">November 21, 2013 6:00am</time>)
|
141
|
-
|
144
|
+
assert_dom_equal expected, local_relative_time(@time, "time-or-date")
|
142
145
|
end
|
143
146
|
end
|
@@ -34,11 +34,14 @@ test "this year", ->
|
|
34
34
|
date = moment().subtract("days", 7).format "MMM D"
|
35
35
|
assertTimeAgo "on #{date}", "days", 7
|
36
36
|
clock.restore()
|
37
|
-
|
37
|
+
|
38
38
|
test "last year", ->
|
39
39
|
date = moment().subtract("days", 366).format "MMM D, YYYY"
|
40
40
|
assertTimeAgo "on #{date}", "days", 366
|
41
41
|
|
42
|
+
test "next year", ->
|
43
|
+
date = moment().add("days", 366).format "MMM D, YYYY"
|
44
|
+
assertTimeAgo "on #{date}", "days", -366
|
42
45
|
|
43
46
|
assertTimeAgo = (string, unit, amount) ->
|
44
47
|
el = document.getElementById "ago"
|
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.
|
4
|
+
version: 1.0.2
|
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:
|
12
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: coffee-rails
|
@@ -39,6 +39,20 @@ dependencies:
|
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rails-dom-testing
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
42
56
|
description:
|
43
57
|
email: javan@basecamp.com
|
44
58
|
executables: []
|