module TZInfo::WithOffset
def if_timezone_offset(result = nil) #:nodoc:
- Private: -
Returns:
-
(Object)
- the result of the block if there is an associated
Other tags:
- Yieldreturn: - the result of the calculation performed if there is
Other tags:
- Yieldparam: result - the `result` parameter.
Yieldparam: period - the associated {TimezoneOffset}.
Other tags:
- Yield: - if there is an associated {TimezoneOffset}, the
Parameters:
-
result
(Object
) -- a result value that can be manipulated by the block
def if_timezone_offset(result = nil) #:nodoc: to = timezone_offset to ? yield(to, result) : result end
def strftime(format)
-
(ArgumentError)
- if `format` is `nil`.
Returns:
-
(String)
- the formatted time.
Parameters:
-
format
(String
) -- the format string.
def strftime(format) raise ArgumentError, 'format must be specified' unless format if_timezone_offset do |o| abbreviation = nil format = format.gsub(/%(%*)Z/) do if $1.length.odd? # Return %%Z so the real strftime treats it as a literal %Z too. "#$1%Z" else "#$1#{abbreviation ||= o.abbreviation.gsub(/%/, '%%')}" end end end super end