aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorHans Bolinder <[email protected]>2018-11-26 13:12:26 +0100
committerHans Bolinder <[email protected]>2018-11-29 14:25:41 +0100
commit8ec20295ba052e5666fc77b66c09445233943814 (patch)
treec6fa88bfea02cc39f4df7d60ec84e54097d14f54 /lib/stdlib/src
parent791742877a893e41d17bf2fd6b0e10c3dfebec8b (diff)
downloadotp-8ec20295ba052e5666fc77b66c09445233943814.tar.gz
otp-8ec20295ba052e5666fc77b66c09445233943814.tar.bz2
otp-8ec20295ba052e5666fc77b66c09445233943814.zip
stdlib: Let calendar:system_time_to_rfc3339() keep fractions
RFC3339 mentions in paragraph 5.1 that if certain conditions are fulfilled, then sorting date and time strings results in a time-ordered sequence. One of the conditions is that the strings must have the same number of fractional second digits. This commits makes sure this is indeed the case.
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/calendar.erl11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/stdlib/src/calendar.erl b/lib/stdlib/src/calendar.erl
index 9a600c1972..bb5d450cd6 100644
--- a/lib/stdlib/src/calendar.erl
+++ b/lib/stdlib/src/calendar.erl
@@ -693,14 +693,11 @@ local_offset(SystemTime, Unit) ->
UniversalSecs = datetime_to_gregorian_seconds(UniversalTime),
LocalSecs - UniversalSecs.
+fraction_str(1, _Time) ->
+ "";
fraction_str(Factor, Time) ->
- case Time rem Factor of
- 0 ->
- "";
- Fraction ->
- FS = io_lib:fwrite(".~*..0B", [log10(Factor), abs(Fraction)]),
- string:trim(FS, trailing, "0")
- end.
+ Fraction = Time rem Factor,
+ io_lib:fwrite(".~*..0B", [log10(Factor), abs(Fraction)]).
fraction(second, _) ->
0;