如何将 dd/MMM/yy hh:mm AM/PM 转换为 iCal 事件格式?
我有一个采用以下格式的日期时间列表:
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Time::Piece 核心模块就足够了:
这假设您的当地时间,并将在输出中包含破折号:
The Time::Piece core module would suffice:
This assumes your localtime and would include dashes in the output:
应该能够使用 DateTime::Format::Strptime 和 日期时间::格式::ICal。
此外,您的输出似乎采用 UTC/GMT(由尾随“Z”表示),但您的输入未指定时区。因此,作为解决方案的一部分,您需要指定应解释输入时间的时区。
另请参阅 http://datetime.perl.org/wiki/datetime/page/Modules
Should be able to do it using a combination of DateTime::Format::Strptime and DateTime::Format::ICal.
Also, your output appears to be in UTC/GMT (indicated by the trailing 'Z'), but your input doesn't specify a timezone. So as part of your solution you will need to specify what time zone the input times should be interpreted in.
See also http://datetime.perl.org/wiki/datetime/page/Modules