用葡萄牙语解析日期
parse dates in portuguese
我想解析一些葡萄牙语日期。
dts = c('19-mai-17', '26-mai-17', '2-jun-17', '9-jun-17', '16-jun-17')
lubridate::parse_date_time(dts, orders = "d-b-y", locale = "pt-BR")
但它只 returns 它与英语重叠的日期,同时抛出一些警告:
[1] NA NA "2017-06-02 UTC" "2017-06-09 UTC" "2017-06-16 UTC"
Warning messages:
1: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
2: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
3: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
4: 2 failed to parse.
我从 locale
获得了代码:https://web.archive.org/web/20161105200145/https://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx
运行 windows 7
这可能只是使用正确的语言环境代码的问题。在 MacOS 上 pt_BR
对我来说工作正常。事实证明,在 Windows 上,您可能想尝试 Portuguese_Brazil.1252
。在任何情况下,更改每个会话的 LC_TIME
语言环境是通过使用
完成的
Sys.setlocale(category = "LC_TIME", locale = "pt_BR")
我想解析一些葡萄牙语日期。
dts = c('19-mai-17', '26-mai-17', '2-jun-17', '9-jun-17', '16-jun-17')
lubridate::parse_date_time(dts, orders = "d-b-y", locale = "pt-BR")
但它只 returns 它与英语重叠的日期,同时抛出一些警告:
[1] NA NA "2017-06-02 UTC" "2017-06-09 UTC" "2017-06-16 UTC"
Warning messages:
1: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
2: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
3: In Sys.setlocale("LC_TIME", locale) :
OS reports request to set locale to "pt-BR" cannot be honored
4: 2 failed to parse.
我从 locale
获得了代码:https://web.archive.org/web/20161105200145/https://msdn.microsoft.com/en-us/library/ee825488(v=cs.20).aspx
运行 windows 7
这可能只是使用正确的语言环境代码的问题。在 MacOS 上 pt_BR
对我来说工作正常。事实证明,在 Windows 上,您可能想尝试 Portuguese_Brazil.1252
。在任何情况下,更改每个会话的 LC_TIME
语言环境是通过使用
Sys.setlocale(category = "LC_TIME", locale = "pt_BR")