| 1 | class Time |
| 2 | def iso8601 |
| 3 | format = "%04d-%02d-%02dT%02d:%02d:%02d.%06d" |
| 4 | if utc? |
| 5 | format << "Z" |
| 6 | end |
| 7 | usec_workaround = usec |
| 8 | # https://github.com/mruby/mruby/issues/6059 |
| 9 | usec_workaround = 0 if usec_workaround < 0 |
| 10 | format % [year, month, day, hour, min, sec, usec_workaround] |
| 11 | end |
| 12 | end |