Twitte...::Util(3pm)

πŸ’– Twitter::API::Util β€” bestie edition πŸ’–

okay so real talk: this is Twitter::API::Util, a lil Perl module from the Twitter::API fam (that's the 3pm manual-page crew, perl documentation section 3, user-contributed). It's the utility drawer of the group chat β€” all the little helper functions you keep needing when you're out here wrestling with the Twitter API. 🐦✨

VERSION: this is version 1.0006, periodt.


🌸 SYNOPSIS 🌸

okay bestie here's the whole vibe in one block, copy it, love it, use it:

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;
}

like… look at that. timestamps converted, errors checked, whole thing ate. πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

it exports helpful utility functions. that's it, that's the description, no notes. πŸŽ€


✨ METHODS ✨

🌈 timestamp_to_gmtime

hands you back gmtime made from a Twitter timestamp string. for the full tea, go peek at "gmtime-EXPR" in perlfunc. ⭐

🌈 timestamp_to_localtime

hands you back localtime for a Twitter timestamp string. the whole story lives at "localtime-EXPR" in perlfunc. πŸ•

🌈 timestamp_to_time

hands you back a UNIX epoch time for a Twitter timestamp string. details are at "time" in perlfunc. ⏳

🌈 is_twitter_api_error

returns true if the scalar you passed in is a Twitter::API::Error. otherwise it returns false. that's the whole function, she's simple and she's iconic. 😌


πŸ‘‘ AUTHOR πŸ‘‘

Marc Mims <marc@questright.com> β€” shoutout to the icon who built this 🫢


This software is copyright (c) 2015-2021 by Marc Mims.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

ngl that's the good kind of license, free software, same terms as Perl 5 itself, no cap πŸ’–

and that's a wrap bestie πŸŽ€ this page came to you courtesy of perl v5.32.1, dated 2021-09-11, from the Twitter::API::Util manual (section 3pm, user contributed Perl documentation). go forth and convert those timestamps, main character πŸ’…βœ¨

πŸ“¦ where this page comes from