Method: Time#xmlschema

Defined in:
lib/mtp.rb

#xmlschema(fraction_digits = 0) ⇒ Object



255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/mtp.rb', line 255

def xmlschema(fraction_digits=0)
  sprintf('%d%02d%02dT%02d%02d', #%02d',
    year, mon, day, hour, min)+ #, sec) +
  if fraction_digits == 0
    ''
  elsif fraction_digits <= 6
    '.' + sprintf('%06d', usec)[0, fraction_digits]
  else
    '.' + sprintf('%06d', usec) + '0' * (fraction_digits - 6)
  end +
  if utc?
    'Z'
  else
    off = utc_offset
    sign = off < 0 ? '-' : '+'
    sprintf('%s%02d%02d', sign, *(off.abs / 60).divmod(60))
  end
end