date_output 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +15 -7
- data/lib/date_output/version.rb +1 -1
- data/lib/date_output.rb +21 -7
- 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
|
-
|
24
|
-
|
25
|
-
|
23
|
+
self.full_date_with_time(date) #=> Thursday 28th March 2013 14:42pm
|
24
|
+
|
25
|
+
self.short_date_with_time(date) #=> Thu 28th Mar 13 14:42pm
|
26
26
|
|
27
|
-
|
27
|
+
self.numbered_date_with_time(date) #=> 28/03/2013 14:42pm
|
28
28
|
|
29
|
-
|
29
|
+
self.numbered_date(date) #=> 28/03/2013
|
30
30
|
|
31
|
-
|
31
|
+
self.full_date(date) #=> Thursday 28th March 2013
|
32
32
|
|
33
|
-
|
33
|
+
self.short_date(date) #=> Thu 28th Mar 13
|
34
|
+
|
35
|
+
You can also pass in some options to to customise the output.
|
36
|
+
|
37
|
+
self.numbered_date_with_time(date, options={:seperator => "-"}) #=> 28-03-2013 14:42pm
|
38
|
+
|
39
|
+
Current options are:
|
40
|
+
|
41
|
+
:seperator => string:: This is the seperator used between the numbered dates. If you do not specify this the default of "/" will be used.
|
34
42
|
|
35
43
|
## Contributing
|
36
44
|
|
data/lib/date_output/version.rb
CHANGED
data/lib/date_output.rb
CHANGED
@@ -3,30 +3,44 @@ require "date_output/version"
|
|
3
3
|
|
4
4
|
module DateOutput
|
5
5
|
|
6
|
-
def self.full_date_with_time(date)
|
6
|
+
def self.full_date_with_time(date, options={})
|
7
|
+
set_options(options)
|
7
8
|
date.strftime("%A #{date.day.ordinalize} %B %Y %H:%M%P")
|
8
9
|
end
|
9
10
|
|
10
|
-
def self.short_date_with_time(date)
|
11
|
+
def self.short_date_with_time(date, options={})
|
12
|
+
set_options(options)
|
11
13
|
date.strftime("%a #{date.day.ordinalize} %b %y %H:%M%P")
|
12
14
|
end
|
13
15
|
|
14
|
-
def self.numbered_date_with_time(date)
|
15
|
-
|
16
|
+
def self.numbered_date_with_time(date, options={})
|
17
|
+
set_options(options)
|
18
|
+
date.strftime("%d#{@seperator}%m#{@seperator}%Y %H:%M%P")
|
16
19
|
end
|
17
20
|
|
18
|
-
def self.numbered_date(date)
|
21
|
+
def self.numbered_date(date, options={})
|
22
|
+
set_options(options)
|
19
23
|
date.strftime("%d/%m/%Y")
|
20
24
|
end
|
21
25
|
|
22
|
-
def self.full_date(date)
|
26
|
+
def self.full_date(date, options={})
|
27
|
+
set_options(options)
|
23
28
|
date.strftime("%A #{date.day.ordinalize} %B %Y")
|
24
29
|
end
|
25
30
|
|
26
|
-
def self.short_date(date)
|
31
|
+
def self.short_date(date, options={})
|
32
|
+
set_options(options)
|
27
33
|
date.strftime("%a #{date.day.ordinalize} %b %y")
|
28
34
|
end
|
29
35
|
|
36
|
+
private
|
37
|
+
def self.set_options(options)
|
38
|
+
# options.each do |k,v|
|
39
|
+
# instance_variable_set("@#{k}",v)
|
40
|
+
# end
|
41
|
+
@seperator = options[:seperator] || "/"
|
42
|
+
end
|
43
|
+
|
30
44
|
end
|
31
45
|
|
32
46
|
require 'date_output/railtie' if defined?(Rails)
|