How to display locale sensitive time format without seconds in python

前端 未结 4 455
清歌不尽
清歌不尽 2020-12-20 12:38

I can output a locale sensitive time format using strftime(\'%X\'), but this always includes seconds. How might I display this time format without seconds?

4条回答
  •  温柔的废话
    2020-12-20 13:14

    I would suggest special casing the returned T_FMT as there aren't that many to consider really:

    $ for l in $(locale -a | grep utf8); do locale | cut -d= -f1 | LANG=$l xargs locale -kc | grep ^t_fmt=; done | sort -u
    
    t_fmt="%H:%M:%S"
    t_fmt="%H.%M.%S"
    t_fmt="%H시 %M분 %S초"
    t_fmt="ཆུ་ཚོད%Hཀསར་མ%Mཀསར་ཆ%S"
    t_fmt="%H时%M分%S秒"
    t_fmt="%H时%M分%S秒 %Z"
    t_fmt="%H時%M分%S秒"
    t_fmt="%I.%M.%S %p"
    t_fmt="%I:%M:%S  %Z"
    t_fmt="%I:%M:%S %Z"
    t_fmt="%I.%M.%S. %Z"
    t_fmt="%I時%M分%S秒 %Z"
    t_fmt="kl. %H.%M %z"
    t_fmt="%k,%M,%S"
    t_fmt="%k:%M:%S"
    t_fmt="%l:%M:%S"
    t_fmt="%OH:%OM:%OS"
    t_fmt="%OI:%OM:%OS %p"
    t_fmt="%p%I.%M.%S %Z"
    t_fmt="%r"
    t_fmt="%t"
    t_fmt="%T"
    t_fmt="%Z %I:%M:%S "
    

提交回复
热议问题