Class: Release::Notes::DateFormatter
- Inherits:
-
Object
- Object
- Release::Notes::DateFormatter
- Includes:
- Configurable
- Defined in:
- lib/release/notes/date_formatter.rb
Constant Summary collapse
- HUMANIZED =
"%B %d, %Y %r %Z"
Instance Attribute Summary collapse
-
#date ⇒ Object
readonly
Returns the value of attribute date.
Instance Method Summary collapse
-
#humanize ⇒ String
Format date.
-
#initialize(date = nil) ⇒ DateFormatter
constructor
Format the date.
Constructor Details
#initialize(date = nil) ⇒ DateFormatter
Format the date
15 16 17 18 |
# File 'lib/release/notes/date_formatter.rb', line 15 def initialize(date = nil) Time.zone = config_timezone @date = date.present? ? Time.zone.parse(date) : Time.zone.now end |
Instance Attribute Details
#date ⇒ Object (readonly)
Returns the value of attribute date.
7 8 9 |
# File 'lib/release/notes/date_formatter.rb', line 7 def date @date end |
Instance Method Details
#humanize ⇒ String
Format date
ex: "January 17, 2019 10:22:53 PM EST"
26 27 28 |
# File 'lib/release/notes/date_formatter.rb', line 26 def humanize date.strftime(HUMANIZED) end |