Module: Origen::Utility::TimeAndDate
- Included in:
- Origen, Application::Release, VersionString
- Defined in:
- lib/origen/utility/time_and_date.rb
Overview
Collection of methods related to time and dates
Instance Method Summary collapse
-
#time_now(options = {}) ⇒ Object
Returns the current time in this format: 05-Jun-2010 10:05AM.
Instance Method Details
#time_now(options = {}) ⇒ Object
Returns the current time in this format: 05-Jun-2010 10:05AM
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/origen/utility/time_and_date.rb', line 7 def time_now( = {}) = { underscore: false, format: :human, include_time: true }.merge() # Nice description of time format options # http://wesgarrison.us/2006/03/12/ruby-strftime-options-for-date-formatting/ if [:format] == :human Time.now.strftime('%d-%b-%Y %H:%M%p') elsif [:format] == :universal time = [:underscore] ? Time.now.strftime('_%H_%M') : Time.now.strftime('%H%M') date = [:underscore] ? Time.now.strftime('%Y_%m_%d') : Time.now.strftime('%Y%m%d') [:include_time] ? date + time : date elsif [:format] == :timestamp Time.now.strftime('%Y%m%d%H%M%S') else fail 'Unknown date format requested!' end end |