Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
Add method formatted_time to Tweet.pm
Browse files Browse the repository at this point in the history
  • Loading branch information
mdom committed Jul 18, 2016
1 parent 91c1a90 commit fcb00fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lib/App/txtnix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ has registry => sub { "https://roster.twtxt.org" };

has [
qw( colors twturl pre_tweet_hook post_tweet_hook config_file
force key_file cert_file plugins cache )
force key_file cert_file plugins cache)
];

sub new {
Expand Down Expand Up @@ -432,6 +432,8 @@ sub parse_twtfile {
substr( $tweet->text, 0, $self->character_limit ) );
}

$tweet->formatted_time( $tweet->strftime( $self->time_format ) );

push @tweets, $tweet;
}
}
Expand Down Expand Up @@ -559,10 +561,10 @@ __DATA__
% my $text = $tweet->text;
% $text =~ s/(@\w+)/colored($1, $app->colors->{mention})/ge;
% $text =~ s/(#\w+)/colored($1, $app->colors->{hashtag})/ge;
% my $time = $tweet->strftime( $app->time_format );
% my $time = colored($tweet->formatted_time,$app->colors->{time});
% my $nick = colored($tweet->nick, $app->colors->{nick});
%
* <%= $nick %> (<%= colored($time, $app->colors->{time}) %>):
* <%= $nick %> (<%= $time %>):
% if ( $app->wrap_text ) {
%= wrap('','',$text) . "\n"
% } else {
Expand Down
5 changes: 3 additions & 2 deletions lib/App/txtnix/Tweet.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ use POSIX ();
has [qw(source text)];
has timestamp => sub { Mojo::Date->new() };

has is_metadata => sub { !!@{ shift->command } };
has command => sub { [] };
has is_metadata => sub { !!@{ shift->command } };
has command => sub { [] };
has formatted_time => sub { shift->strftime('%Y-%m-%d %H:%M') };

sub nick {
shift->source->to_string;
Expand Down

0 comments on commit fcb00fe

Please sign in to comment.