mirror of
https://github.com/mnauw/git-remote-hg.git
synced 2026-03-19 08:20:12 +01:00
Refactor timezone functions
Split them into hours and minutes, and use divmod() to make them more readable. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
This commit is contained in:
@@ -72,14 +72,16 @@ def gitmode(flags):
|
||||
return 'l' in flags and '120000' or 'x' in flags and '100755' or '100644'
|
||||
|
||||
def gittz(tz):
|
||||
sign = 1 if tz < 0 else -1
|
||||
return '%+03d%02d' % (sign * (abs(tz) / 3600), abs(tz) % 3600 / 60)
|
||||
sign = 1 if tz >= 0 else -1
|
||||
hours, minutes = divmod(abs(tz), 60 * 60)
|
||||
return '%+03d%02d' % (-sign * hours, minutes / 60)
|
||||
|
||||
def hgtz(tz):
|
||||
tz = int(tz)
|
||||
sign = 1 if tz < 0 else -1
|
||||
tz = ((abs(tz) / 100) * 3600) + ((abs(tz) % 100) * 60)
|
||||
return sign * tz
|
||||
sign = 1 if tz >= 0 else -1
|
||||
hours, minutes = divmod(abs(tz), 100)
|
||||
tz = hours * 60 * 60 + minutes * 60
|
||||
return -sign * tz
|
||||
|
||||
def hgmode(mode):
|
||||
m = { '100755': 'x', '120000': 'l' }
|
||||
|
||||
Reference in New Issue
Block a user