加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – 寻找棕榈星期天

发布时间:2020-12-16 06:21:37 所属栏目:大数据 来源:网络整理
导读:棕榈星期日是复活节前的星期天.通过以下方式可以实现复活节周日: use Time::Moment;use Time::Moment::Adjusters qw(WesternEasterSunday PreviousDayOfWeek);# 2018-04-01T00:00:00Zmy $easter_sunday = Time::Moment-new(year = 2018)-with(WesternEaster
棕榈星期日是复活节前的星期天.通过以下方式可以实现复活节周日:

use Time::Moment;
use Time::Moment::Adjusters qw(WesternEasterSunday PreviousDayOfWeek);

# 2018-04-01T00:00:00Z
my $easter_sunday = Time::Moment->new(year => 2018)->with(WesternEasterSunday);

使用Time::Moment::AdjustersPreviousDayOfWeek(7)可以在此之前找到周日:

06001

The $adjuster adjusts the date to the previous occurrence of the given day of the week [1=Monday,7=Sunday] that is before the date.

但如果我申请这个调整员,我会在五天前得到一个星期二!

# 2018-03-27T00:00:00Z
my $palm_sunday = $easter_sunday->with(PreviousDayOfWeek(7))

由于棕榈星期日总是在复活节星期日前7天,我可以用Time::Moment‘s minus_days(7)实现这一点,但是因为我想找到一些其他假期,使用Time :: Moment :: Adjusters更容易找到,我真的很想找到这种意外行为的根源.

解决方法

谢谢Simon的 report和 PR,感谢@simbabque的测试!我已发货 v0.44 to CPAN.您是开源社区的优秀公民!

– chansen

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读