Re: [PATCH (BUGFIX)] gitweb: Fix handling of fractional timezones in parse_date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Kevin Cernekee <cernekee@xxxxxxxxx> writes:

> It's just a matter of personal preference, but I would find this
> regexp slightly easier to read:
>
> +               ($tz =~ m/^([+\-])([0-9]{2})([0-9]{2})$/);

I'd say "^([-+])(\d\d)(\d\d)$" makes it the most clear.

>> + Â Â Â $tz_sign = ($tz_sign eq '-' ? -1 : +1);
>> + Â Â Â my $local = $epoch + $tz_sign*($tz_hour + ($tz_min/60.0))*3600;
>
> If you wanted to avoid floats, you could do something like:
>
> +       my $local = $epoch + $tz_sign * ($tz_hour * 3600 + $tz_min * 60);

That is not just float-avoidance, but is much more logical.

	(($h * 60) + $m) * 60

may be even more logical and more readable, though.

Care to re-roll the patch?
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]