date_output 1.0.0 → 1.0.1

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 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
- 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
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
- self.numbered_date_with_time(date) => 28/03/2013 14:42pm
27
+ self.numbered_date_with_time(date) #=> 28/03/2013 14:42pm
28
28
 
29
- self.numbered_date(date) => 28/03/2013
29
+ self.numbered_date(date) #=> 28/03/2013
30
30
 
31
- self.full_date(date) => Thursday 28th March 2013
31
+ self.full_date(date) #=> Thursday 28th March 2013
32
32
 
33
- self.short_date(date) => Thu 28th Mar 13
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
 
@@ -1,3 +1,3 @@
1
1
  module DateOutput
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
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
- date.strftime("%d/%m/%Y %H:%M%P")
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_output
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: