use Net::Google::Calendar;
my $cal = Net::Google::Calendar->new;
$cal->login(...);
my $c;
for ($cal->get_calendars) {
$c = $_ if ($_->title eq 'Custom');
}
$cal->set_calendar($c);
for my $event ($cal->get_events) {
print "<pre>" . $event->title . " ". Dumper($event->when) ." </pre>";
}
标题可以正常返回,但我还需要日期,希望能按日期过滤掉我需要的事件(就像我处理该帐户的日历一样,我认为这个模块无论如何都不支持更高级的方式)。打印结果显示肯定有一些东西:
VAR1 = bless(
{
'local_rd_secs' => 0,
'local_rd_days' => 734733,
'rd_nanosecs' => 0,
'locale' => bless(
{
'default_time_format_length' => 'medium',
'native_territory' => 'United States',
'native_language' => 'English',
'native_complete_name' => 'English United States',
'en_language' => 'English',
'id' => 'en_US',
'default_date_format_length' => 'medium',
'en_complete_name' => 'English United States',
'en_territory' => 'United States'
},
'DateTime::Locale::en_US'
),
'local_c' => {
'hour' => 0,
'second' => 0,
'month' => 8,
'quarter' => 3,
'day_of_year' => 231,
'day_of_quarter' => 49,
'minute' => 0,
'day' => 18,
'day_of_week' => 6,
'year' => 2012
},
'utc_rd_secs' => 0,
'formatter' => undef,
'tz' => bless( { 'name' => 'UTC' }, 'DateTime::TimeZone::UTC' ),
'utc_year' => 2013,
'utc_rd_days' => 734733,
'offset_modifier' => 0
},
'DateTime'
);
'DateTime' 是暗示性的,但$event->when->day
根据 DateTime 给出
的,Can't call method "day" without a package or object reference
我认为我在使用 Perl 时很愚蠢。如何使用返回的日期对象(或任何它),以便我可以直接读取日期和/或使其可读?