Skip to content

Instantly share code, notes, and snippets.

@toritori0318
Created February 12, 2012 14:52
Show Gist options
  • Select an option

  • Save toritori0318/1808897 to your computer and use it in GitHub Desktop.

Select an option

Save toritori0318/1808897 to your computer and use it in GitHub Desktop.
Twitterの日付変換とか
package Twitter::Date;
use strict;
use warnings;
use Time::Piece;
sub convert_statuses {
my ($statuses) = @_;
my $len = scalar @$statuses;
$len -= 1 if $len != 0;
for my $i (0..$len) {
$statuses->[$i]->{created_at} = twitter_date($statuses->[$i]->{created_at});
}
return $statuses;
}
sub twitter_date {
my ($twitter_dt) = @_;
return '' unless $twitter_dt;
my $t = Time::Piece->strptime( $twitter_dt, '%a %b %d %T %z %Y' );
$t += 60 * 60 * 9;
return $t;
}
sub twitter_searchdate {
my ($twitter_dt) = @_;
return '' unless $twitter_dt;
my $t = Time::Piece->strptime( $twitter_dt, '%a, %d %b %Y %T %z' );
$t += 60 * 60 * 9;
return $t;
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment