Comment 5 for bug 1479056

Revision history for this message
Diana Clarke (diana-clarke) wrote :

I also worked on removing these warnings, but I took a slightly different approach.

    https://review.openstack.org/#/c/240411

You were explicit, and included the format in all cases:

    BEFORE: timeutils.strtime(timeutils.utcnow())
    AFTER: timeutils.utcnow().strftime('%Y-%m-%dT%H:%M:%S.%f')

Where as my goal was to move toward the simpler .isoformat() where possible:

    BEFORE: timeutils.strtime(timeutils.utcnow())
    AFTER: timeutils.utcnow().isoformat()

The catch is that datetime.isoformat() is not *exactly* the same as '%Y-%m-%dT%H:%M:%S.%f' (when microseconds is 0), but in practice it's probably fine since they are pretty much always timeutils.utcnow() with microseconds. To err on the side of caution though, I intentionally did not change 5 instances of timeutils.strtime in the production path code (vs the unit tests) to be revisited later.

    https://docs.python.org/2/library/datetime.html#datetime.datetime.isoformat

That said, I like a combination of both of our approaches: isoformat when it's safe, and an explicit '%Y-%m-%dT%H:%M:%S.%f' in the production code path when there's some doubt about remaining backwards compatible. I'll update my patch to combine both approaches and add you as an additional author.