如何将dd / MMM / yy hh:mm AM / PM转换为iCal事件格式?(How can I convert dd/MMM/yy hh:mm AM/PM to iCal event for

编程入门 行业动态 更新时间:2024-10-26 21:31:04
如何将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:00

The 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

更多推荐

本文发布于:2023-07-22 19:32:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1222783.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   如何将   事件   格式   yy

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!