gpxpy icon indicating copy to clipboard operation
gpxpy copied to clipboard

Avoid using strftime in format_time

Open ekspla opened this issue 3 years ago • 3 comments

Issue #225

To reduce the processing time and to make the code simple, .isoformat() is used instead of strftime.

TZ format is changed from '+/-HHMM' to '+/-HH:MM'. Both of the formats are allowed in the standard.

ekspla avatar Mar 16 '21 23:03 ekspla

Coverage Status

Coverage increased (+0.05%) to 87.813% when pulling 27eaf87c9a6490be0ba7eaea4e5dcc57f13151db on ekspla:dev into e3733bbd59d11bcbf089f30b286286fcd728bb46 on tkrajina:dev.

coveralls avatar Mar 16 '21 23:03 coveralls

Can someone help me?

Less code resulted in reduced coverage though I wrote a test for the modified function.

Coverall is saying that existing code of dst (daylight saving time ??) in SimpleTZ is uncovered. I do not think that it is well functioning because it is always returning datetime.timedelta(0).

class SimpleTZ(mod_datetime.tzinfo):
    __slots__ = ('offset',)
    def dst(self, dt: Optional[mod_datetime.datetime]) -> mod_datetime.timedelta:
        return mod_datetime.timedelta(0)

What should I do?

ekspla avatar Mar 19 '21 20:03 ekspla

A test for the dst method in SimpleTZ was written. Coverall is not complaining now. This PR is ready for code review.

I am not quite sure what is the best way to test dst because daylight saving time is not fully implemented in SimpleTZ. So, the test is checking nonexistence of dst offsets in UTC times that is okay even after the functional dst is implemented (which is unlikely, though).

I found that by using dst None is returned from mod_datetime.timezone.utc other than timedelta(0) from SimpleTZ. The test is valid for both of the values.

ekspla avatar Mar 21 '21 22:03 ekspla

Merged, thanks!

tkrajina avatar Nov 04 '22 17:11 tkrajina