Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Perl中从日期开始获取一天_Perl - Fatal编程技术网

在Perl中从日期开始获取一天

在Perl中从日期开始获取一天,perl,Perl,有没有办法找出一周中哪一天提供了日期。我将如何用Perl编写此代码 比如说 鉴于2016年2月2日(日-月-年)的产出 注意:不使用任何模块 注意:不使用任何模块 日历很难。不,日历真的很难!很容易出错。使用模块 幸运的是,有一个内置模块来完成这项工作。它必须将日期解析为一个对象。从那里你可以问很多问题 use v5.10; use strict; use warnings; use Time::Piece; my $time = Time::Piece->strptime("02-02

有没有办法找出一周中哪一天提供了日期。我将如何用Perl编写此代码

比如说

鉴于2016年2月2日(日-月-年)的产出 注意:不使用任何模块

注意:不使用任何模块

日历很难。不,日历真的很难!很容易出错。使用模块

幸运的是,有一个内置模块来完成这项工作。它必须将日期解析为一个对象。从那里你可以问很多问题

use v5.10;
use strict;
use warnings;
use Time::Piece;

my $time = Time::Piece->strptime("02-02-2016", "%d-%m-%Y");
say $time->fullday;

参见日期::Manip()2016年2月2日星期二day@Christopher如果没有模块,这是可能的。到目前为止,我们已经尝试了什么?输入格式总是这样的
dd-mm-yyyy
?如果您想要一种数学方法来确定星期几的数字(您可以使用该数字下标到一个日期名称数组中),请查阅John Conway的世界末日算法。