diff options
author | Nicholas Dainty <nick@npad.co.uk> | 2009-01-10 14:09:29 +0000 |
---|---|---|
committer | gbuesing <gbuesing@gmail.com> | 2009-01-11 13:56:07 -0600 |
commit | 296ca4da1700eb27a7043112d22027444ea0e548 (patch) | |
tree | e2c217bb6cd620ece4b57a20c9b42f2c456be7d9 /activesupport/lib | |
parent | f1fff0a4808f2bcdca0a640fb6530d7c33fe69dc (diff) | |
download | rails-296ca4da1700eb27a7043112d22027444ea0e548.tar.gz rails-296ca4da1700eb27a7043112d22027444ea0e548.tar.bz2 rails-296ca4da1700eb27a7043112d22027444ea0e548.zip |
TimeWithZone#xmlschema accepts optional fraction_digits argument [#1725 state:resolved]
Diffstat (limited to 'activesupport/lib')
-rw-r--r-- | activesupport/lib/active_support/time_with_zone.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 99be89fdf0..ec28f9801a 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -99,8 +99,12 @@ module ActiveSupport "#{time.strftime('%a, %d %b %Y %H:%M:%S')} #{zone} #{formatted_offset}" end - def xmlschema - "#{time.strftime("%Y-%m-%dT%H:%M:%S")}#{formatted_offset(true, 'Z')}" + def xmlschema(fraction_digits = 0) + fraction = if fraction_digits > 0 + ".%i" % time.usec.to_s[0, fraction_digits] + end + + "#{time.strftime("%Y-%m-%dT%H:%M:%S")}#{fraction}#{formatted_offset(true, 'Z')}" end alias_method :iso8601, :xmlschema |