date_output 1.0.7 → 1.0.9
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/README.md +14 -6
- data/lib/date_output/version.rb +1 -1
- data/lib/date_output/view_helpers.rb +16 -0
- data/lib/date_output.rb +20 -0
- metadata +1 -1
data/README.md
CHANGED
@@ -20,17 +20,25 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
In your view use the helpers to output the formatted dates.
|
22
22
|
|
23
|
-
|
23
|
+
full_date_with_time(date) #=> Thursday 28th March 2013 14:42pm
|
24
24
|
|
25
|
-
|
25
|
+
short_date_with_time(date) #=> Thu 28th Mar 13 14:42pm
|
26
26
|
|
27
|
-
|
27
|
+
numbered_date_with_time(date) #=> 28/03/2013 14:42pm
|
28
28
|
|
29
|
-
|
29
|
+
numbered_date(date) #=> 28/03/2013
|
30
30
|
|
31
|
-
|
31
|
+
full_date(date) #=> Thursday 28th March 2013
|
32
32
|
|
33
|
-
|
33
|
+
short_date(date) #=> Thu 28th Mar 13
|
34
|
+
|
35
|
+
long_date_no_day(date) #=> 28th March 2013
|
36
|
+
|
37
|
+
short_date_no_day(date) #=> 28th Mar 13
|
38
|
+
|
39
|
+
long_date_no_day_with_time(date) #=> 28th March 2013 14:42pm
|
40
|
+
|
41
|
+
short_date_no_day_with_time(date) #=> 28th Mar 13 14:42pm
|
34
42
|
|
35
43
|
You can also pass in some options to to customise the output. These are passes in as a hash. For example:
|
36
44
|
|
data/lib/date_output/version.rb
CHANGED
@@ -25,5 +25,21 @@ module DateOutput
|
|
25
25
|
DateOutput.short_date(date,options)
|
26
26
|
end
|
27
27
|
|
28
|
+
def long_date_no_day(date, options={})
|
29
|
+
DateOutput.long_date_no_day(date, options)
|
30
|
+
end
|
31
|
+
|
32
|
+
def short_date_no_day(date, options={})
|
33
|
+
DateOutput.short_date_no_day(date, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def long_date_no_day_with_time(date, options={})
|
37
|
+
DateOutput.long_date_no_day_with_time(date, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def short_date_no_day_with_time(date, options={})
|
41
|
+
DateOutput.long_date_no_day_with_time(date, options)
|
42
|
+
end
|
43
|
+
|
28
44
|
end
|
29
45
|
end
|
data/lib/date_output.rb
CHANGED
@@ -33,6 +33,26 @@ module DateOutput
|
|
33
33
|
date.strftime("%a #{date.day.ordinalize} %b %y")
|
34
34
|
end
|
35
35
|
|
36
|
+
def self.long_date_no_day(date, options)
|
37
|
+
set_options(options)
|
38
|
+
date.strftime("#{date.day.ordinalize} %B %Y")
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.short_date_no_day(date, options)
|
42
|
+
set_options(options)
|
43
|
+
date.strftime("#{date.day.ordinalize} %b %y")
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.long_date_no_day_with_time(date, options)
|
47
|
+
set_options(options)
|
48
|
+
date.strftime("#{date.day.ordinalize} %B %Y %H:%M%P")
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.short_date_no_day_with_time(date, options)
|
52
|
+
set_options(options)
|
53
|
+
date.strftime("#{date.day.ordinalize} %b %y %H:%M%P")
|
54
|
+
end
|
55
|
+
|
36
56
|
private
|
37
57
|
def self.set_options(options)
|
38
58
|
# options.each do |k,v|
|