module DateByExample
Constants
- DAY_NAME_ABBREV_RE
- DAY_NAME_RE
- DAY_RE
- DAY_WITH_ZERO_RE
- MAJOR
- MINOR
- MONTH_NAME_ABBREV_RE
todo/fix: improve end of MONTH_RE
do NOT use \b - also break on everything but a-z incl. numbers/digits - (double) check!!!
- MONTH_NAME_RE
note: May is turned into an abbreviated month name (%b)
- PATCH
- TIME_RE
- TIME_WITH_ZERO_RE
- VERSION
- YEAR_RE
Public Class Methods
root()
click to toggle source
# File lib/date-formatter/version.rb, line 16 def self.root File.expand_path( File.dirname(File.dirname(File.dirname(__FILE__))) ) end
to_strftime( spec )
click to toggle source
# File lib/date-formatter.rb, line 67 def self.to_strftime( spec ) spec = spec.gsub( MONTH_NAME_RE, '%B' ) # %B - The full month name ("January") spec = spec.gsub( MONTH_NAME_ABBREV_RE, '%b') # %b - The abbreviated month name ("Jan") spec = spec.gsub( DAY_NAME_RE, '%A' ) # %A - The full weekday name ("Sunday") spec = spec.gsub( DAY_NAME_ABBREV_RE, '%a') # %a - The abbreviated weekday name ("Sun") spec = spec.gsub( TIME_WITH_ZERO_RE, '%H:%M' ) # %H - Hour of the day, 24-hour clock (00..23) # %M - Minute of the hour (00..59) spec = spec.gsub( TIME_RE, '%-H:%M' ) spec = spec.gsub( YEAR_RE, '%Y' ) # %Y - Year with century spec = spec.gsub( DAY_WITH_ZERO_RE, '%d' ) # %d - Day of the month (01..31) spec = spec.gsub( DAY_RE, '%-d' ) # %d - Day of the month without a leading zero (1..31) ## add some "higher-level" symbolic format shortcuts too spec = spec.gsub( 'YYYY', '%Y' ) spec = spec.gsub( 'YY', '%y' ) spec = spec.gsub( 'MM', '%m' ) spec = spec.gsub( 'DD', '%d' ) spec = spec.gsub( 'D', '%-d') spec = spec.gsub( 'hh', '%H' ) spec = spec.gsub( 'h', '%-H' ) spec = spec.gsub( 'mm', '%M' ) spec = spec.gsub( 'ss', '%S' ) spec end
version()
click to toggle source
# File lib/date-formatter/version.rb, line 8 def self.version VERSION end