timedatectl: stop using xstrftime
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 18 Oct 2017 14:15:09 +0000 (16:15 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 18 Oct 2017 14:30:37 +0000 (16:30 +0200)
commit14ce0c25c28ba58e80084e28b4f23884199900e4
treeafee4f156a2c23049eab9701ee14d36d39709b0b
parentb996f7e41abeb5ece7c5f27958e0f08a1edff3ba
timedatectl: stop using xstrftime

When using strftime in arbitrary locales, we cannot really say how big the
buffer should be. Let's make the buffer "large", which will work fine pretty
much always, and just print n/a if the timestamp does not fit. strftime returns
0 if the buffer is too small and a NUL-terminated string otherwise, so we
can drop the size specifications in string formatting.

$ export LANG=fa_IR.UTF-8
$ date
چهارشنبه ۱۸ اكتبر ۱۷، ساعت ۱۰:۵۴:۲۴ (+0330)
$ timedatectl
Assertion 'xstrftime: a[] must be big enough' failed at ../src/timedate/timedatectl.c:105, function print_status_info(). Aborting.

now:

$ timedatectl
        Local time: چهارشنبه 2017-10-18 16:29:40 CEST
    Universal time: چهارشنبه 2017-10-18 14:29:40 UTC
          RTC time: چهارشنبه 2017-10-18 14:29:40


https://bugzilla.redhat.com/show_bug.cgi?id=1503452
src/basic/time-util.h
src/timedate/timedatectl.c