首页 > 解决方案 > 如何使用 format_cldr("LLL") 打印首字母大写的月份名称

问题描述

我正在使用 format_cldr("LLL") 这给了我 jan, feb, mar, ... 但我需要首字母大写:Jan, Feb, Mar, ...

我尝试使用 ucfirst(),但没有成功。

这是我的一段代码:

while ($i < 13) {
  my $d = DateTime->new(year=>1111, month => $i, day=>1);
  $d->set_locale($self->context->locale);
  @$climate[$i-1]->{month_name} = $d->format_cldr("LLL");
  $i = $i + 1;
}

需要帮助,提前谢谢

标签: perl

解决方案


你说你试过ucfirst了,但你没有告诉我们怎么做。

这将起作用:

 @$climate[$i-1]->{month_name} = ucfirst $d->format_cldr("LLL");

推荐阅读