logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Twitter::API::Util - Utilities for working with the Twitter API

Author

       Marc Mims <marc@questright.com>

Description

       Exports helpful utility functions.

Methods

timestamp_to_gmtime
       Returns "gmtime" from a Twitter timestamp string. See "gmtime-EXPR" in perlfunc for details.

   timestamp_to_localtime
       Returns "localtime" for a Twitter timestamp string. See "localtime-EXPR" in perlfunc for details.

   timestamp_to_time
       Returns a UNIX epoch time for a Twitter timestamp string. See "time" in perlfunc for details.

   is_twitter_api_error
       Returns true if the scalar passed to it is a Twitter::API::Error. Otherwise, it returns false.

Name

       Twitter::API::Util - Utilities for working with the Twitter API

Synopsis

           use Twitter::API::Util ':all';

           # Given a timestamp in Twitter's text format:
           my $ts = $status->{created_at}; # "Wed Jun 06 20:07:10 +0000 2012"

           # Convert it UNIX epoch seconds (a Perl "time" value):
           my $time = timestamp_to_time($status->{created_at});

           # Or a Perl localtime:
           my $utc = timestamp_to_timepiece($status->{created_at});

           # Or a Perl gmtime:
           my $utc = timestamp_to_gmtime($status->{created_at});

           # Check to see if an exception is a Twitter::API::Error
           if ( is_twitter_api_error($@) ) {
               warn "Twitter API error: " . $@->twitter_error_text;
           }

Version

       version 1.0006

See Also