Sha256: b83e4544a776e8467c05e8ea218d43262f3a8bd8a46f9f23aeb4831e24a9e3fb
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
# encoding: utf-8 # Extend DateTime with methods available in ruby 1.9 class DateTime # TODO: remove the rbx guard when fractional seconds are handled properly in 1.9 mode SEC_FRACTION_MULTIPLIER = RUBY_VERSION < '1.9' ? 60 * 60 * 24 : 1 # Return the DateTime in ISO8601 date-time format # # @param [Integer] time_scale # the number of significant digits to use for fractional seconds # # @return [#to_s] # # @todo Remove once backports adds this method # # @api private def iso8601(time_scale = 0) super() + iso8601_timediv(time_scale) end unless method_defined?(:iso8601) && instance_method(:iso8601).arity == 1 private # Return the time with fraction seconds # # @param [Integer] time_scale # the number of significant digits to use for fractional seconds # # @return [#to_s] # # @api private def iso8601_timediv(time_scale) date_time = frozen? ? dup : self fractional_seconds = unless time_scale.zero? '.%0*d' % [ time_scale, date_time.sec_fraction * SEC_FRACTION_MULTIPLIER * 10**time_scale ] end date_time.strftime("T%T#{fractional_seconds}%Z") end unless method_defined? :iso8601_timediv end # class Date
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
veritas-sql-generator-0.0.7 | lib/veritas/sql/generator/core_ext/date_time.rb |