Perl module: Time::Moment

Module安装方法:

http://www.cpan.org/modules/INSTALL.html

cpan App::cpanminus

cpanm Time::Moment

 

使用说明:

https://metacpan.org/pod/Time::Moment

 

离线查看doc方法:

perldoc Time::Moment

 

使用案例:

use v5.30.3;
use Time::Moment;

# my $dt = Time::Moment->from_epoch( time );
# say $dt;

my $dt = Time::Moment->new(
    year => 2021,
    month => 1,
    day => 2,
);

my $issue_id = 8911;

foreach(0..51) {
    my $tmp = $dt->plus_days($dt->day_of_month + 7 * $_);
    printf "%d_%4d%02d%02d\n", $issue_id, $tmp->year, $tmp->month, $tmp->day_of_month;
    $issue_id += 1;
}

 

输出结果:

8911_20210104
8912_20210111
8913_20210118
8914_20210125
8915_20210201
8916_20210208
8917_20210215
8918_20210222
8919_20210301
...

 

posted @ 2021-07-22 12:38  profesor  阅读(51)  评论(0编辑  收藏  举报