aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2014-12-12 23:50:03 +0100
committerHolger Weiss <holger@zedat.fu-berlin.de>2014-12-12 23:50:03 +0100
commit466278fde1675a14c4d20d6e0de2636beeea7d71 (patch)
tree4f9ad1e6cf9442e4aab82d3051a6c8de51b53fe4 /src
parentAdd fractions of seconds to <delay/> timestamps (diff)
Let jlib use "B" instead of "w" to format integers
As a small optimization, use io:format's "B" control sequence to format integers. We don't need to let Erlang figure out the data type if we already know it.
Diffstat (limited to 'src')
-rw-r--r--src/jlib.erl16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/jlib.erl b/src/jlib.erl
index f15d71a3c..dd2cc38dc 100644
--- a/src/jlib.erl
+++ b/src/jlib.erl
@@ -683,18 +683,18 @@ timestamp_to_iso({{Year, Month, Day},
{Hour, Minute, Second}},
Timezone) ->
Timestamp_string =
- lists:flatten(io_lib:format("~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w",
+ lists:flatten(io_lib:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B",
[Year, Month, Day, Hour, Minute, Second])),
Timezone_string = case Timezone of
utc -> "Z";
{Sign, {TZh, TZm}} ->
- io_lib:format("~s~2..0w:~2..0w", [Sign, TZh, TZm]);
+ io_lib:format("~s~2..0B:~2..0B", [Sign, TZh, TZm]);
{TZh, TZm} ->
Sign = case TZh >= 0 of
true -> "+";
false -> "-"
end,
- io_lib:format("~s~2..0w:~2..0w",
+ io_lib:format("~s~2..0B:~2..0B",
[Sign, abs(TZh), TZm])
end,
{iolist_to_binary(Timestamp_string), iolist_to_binary(Timezone_string)}.
@@ -703,7 +703,7 @@ timestamp_to_iso({{Year, Month, Day},
timestamp_to_iso({{Year, Month, Day},
{Hour, Minute, Second}}) ->
- iolist_to_binary(io_lib:format("~4..0w~2..0w~2..0wT~2..0w:~2..0w:~2..0w",
+ iolist_to_binary(io_lib:format("~4..0B~2..0B~2..0BT~2..0B:~2..0B:~2..0B",
[Year, Month, Day, Hour, Minute, Second])).
-spec now_to_utc_string(erlang:timestamp()) -> binary().
@@ -718,8 +718,8 @@ now_to_utc_string({MegaSecs, Secs, MicroSecs}, Precision) ->
calendar:now_to_universal_time({MegaSecs, Secs,
MicroSecs}),
FracOfSec = round(MicroSecs / math:pow(10, 6 - Precision)),
- list_to_binary(io_lib:format("~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w.~*."
- ".0wZ",
+ list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B.~*."
+ ".0BZ",
[Year, Month, Day, Hour, Minute, Second,
Precision, FracOfSec])).
@@ -739,8 +739,8 @@ now_to_local_string({MegaSecs, Secs, MicroSecs}) ->
end,
{{Year, Month, Day}, {Hour, Minute, Second}} =
LocalTime,
- list_to_binary(io_lib:format("~4..0w-~2..0w-~2..0wT~2..0w:~2..0w:~2..0w.~6."
- ".0w~s~2..0w:~2..0w",
+ list_to_binary(io_lib:format("~4..0B-~2..0B-~2..0BT~2..0B:~2..0B:~2..0B.~6."
+ ".0B~s~2..0B:~2..0B",
[Year, Month, Day, Hour, Minute, Second,
MicroSecs, Sign, H, M])).