②话不说▼ 2013▼ 手册 ubuntu 日期 i18n locale

018.Ubuntu修改Locale中的日期格式

不太习惯en_US默认的日时表示,更喜欢2013-07-16 23:12:59这种。

@史荣久 / 2013-07-16 / CC-BY-SA-3.0

1.实现目标

环境:
Ubuntu12.04LTS,64bit

目标:
1) 日时改成 2013-07-16 23:12:59
2) 时间改成 24小时制

2.操作手册

#1.Text-to-unicode converter
cat >encoder.py<<EOF
#!/usr/bin/python

def encode(string):
    newstring = str()
    for ch in string:
        newstring += "<U%04X>" % ord(ch)
    return newstring

if __name__ == '__main__':
    import sys
    print encode(sys.argv[1])
    
EOF
chmod +x encoder.py

#2.Creating a locale from scratch
cp /usr/share/i18n/locales/en_US en_US@trydofor
gedit en_US@trydofor &

#d_t_fmt
#./encoder.py '%Y-%m-%d %H:%M:%S'
#<U0025><U0059><U002D><U0025><U006D><U002D><U0025><U0064><U0020><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053>
#d_fmt
#./encoder.py "%Y-%m-%d"
#<U0025><U0059><U002D><U0025><U006D><U002D><U0025><U0064>
#t_fmt
#./encoder.py "%H:%M:%S"
#<U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053>
#date_fmt
#./encoder.py "%Y-%m-%d %H:%M:%S %w"
#<U0025><U0059><U002D><U0025><U006D><U002D><U0025><U0064><U0020><U0025><U0048><U003A><U0025><U004D><U003A><U0025><U0053><U0020><U0025><U0077>

#3.Installing your custom locale
#bind 
sudo localedef -i en_US@trydofor -f UTF-8 -cv en_US.UTF-8
#copy
sudo cp en_US@trydofor /usr/share/i18n/locales/
#gen
sudo locale-gen
#check
locale
locale -a

3.参考资料

http://askubuntu.com/questions/21316/how-can-i-customize-a-system-locale
http://wiki.ubuntu.org.cn/Locale

《018.Ubuntu修改Locale中的日期格式》 不太习惯en_US默认的日时表示,更喜欢2013-07-16 23:12:59这种。
题图:友人请客(冲绳菜,海葡萄,2014-07-18),留个纪念吧。