Perl 中是否有一个模块可以从日期格式字符串生成全局模式?
我想从日期格式字符串生成全局模式,例如
%Y-%m-%d
应该变成
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
while
%C (e.g., Sat Nov 19 21:05:57 1994)
应该变成
[A-Z][a-z][a-z] [A-Z][a-z][a-z] [0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]
我想知道,类似的东西是否已经存在。
I want to generate glob patterns from date format strings, e.g.
%Y-%m-%d
should become
[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]
While
%C (e.g., Sat Nov 19 21:05:57 1994)
should become
[A-Z][a-z][a-z] [A-Z][a-z][a-z] [0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] [0-9][0-9][0-9][0-9]
I am wondering, if something like that already exists.
这不是对您问题的直接答案,但有助于实现您可能想要的目标。
使用 CPAN 中的模块:Date::Parse。它解析不同语言的各种日期格式。
来自文档:
<代码>
$lang = Date::Language->new('德语');
$lang->str2time("1996年6月25日21:09:55 +0100");
文档包含多种可供您使用的不同日期格式。
This is not a direct answer to your question, but helpful to achieve what you might want.
use the module from CPAN: Date::Parse. It parses various date formats in different language.
From the docs:
$lang = Date::Language->new('German');
$lang->str2time("25 Jun 1996 21:09:55 +0100");
Document includes several different date formats that you can use.