如何将dd / MMM / yy hh:mm AM / PM转换为iCal事件格式?(How can I convert dd/MMM/yy hh:mm AM/PM to iCal event format?)
我有这种格式的日期时间列表:
05/Jan/12 8:00 AM
这一天总是两位数字,但小时可以是一位或两位数字。
我想将其转换为iCal格式:
20120105T080000Z
有没有一个模块可以做到这一点?
I have a list of date-times in this format:
05/Jan/12 8:00 AM
The day is always two digits, but the hour can be either one or two digits.
I'd like to convert that to iCal format:
20120105T080000Z
Is there a module that does this?
最满意答案
Time :: Piece核心模块就足够了:
#!/usr/bin/env perl use strict; use warnings; use Time::Piece; my $str = q(05/Jan/12 8:00 AM); my $t = Time::Piece->strptime($str,"%d/%b/%y %I:%M %p"); print $t->datetime, "\n";这假定你的本地时间,并在输出中包含破折号:
2012-01-05T08:00:00The Time::Piece core module would suffice:
#!/usr/bin/env perl use strict; use warnings; use Time::Piece; my $str = q(05/Jan/12 8:00 AM); my $t = Time::Piece->strptime($str,"%d/%b/%y %I:%M %p"); print $t->datetime, "\n";This assumes your localtime and would include dashes in the output:
2012-01-05T08:00:00更多推荐
发布评论