about summary refs log tree commit diff stats
path: root/ara.pl
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-06-06 14:48:17 +0530
committerAndinus <andinus@nand.sh>2020-06-06 14:48:17 +0530
commit60e9db79a3940d8d719d8028d204d5389c131f19 (patch)
treec6f122af9ba534902bde5eb16ae2e2b7920e444b /ara.pl
parentf6be7b4f01409b107afdf9d61942b5db7db42ecb (diff)
downloadara-60e9db79a3940d8d719d8028d204d5389c131f19.tar.gz
Use Time::Moment for $file_mtime instead of DateTime
First step to replacing DateTime with Time::Moment, DateTime is very
huge, no need to load that large module for simple tasks, it'll also
make the program run faster.

This comparison happens in utc time instead of converting it to other
time zone which was meaningless anyways.
Diffstat (limited to 'ara.pl')
-rwxr-xr-xara.pl8
1 files changed, 3 insertions, 5 deletions
diff --git a/ara.pl b/ara.pl
index fec9c3d..b3bbff9 100755
--- a/ara.pl
+++ b/ara.pl
@@ -6,6 +6,7 @@ use feature 'say';
 
 use DateTime qw( );
 use Path::Tiny;
+use Time::Moment;
 use JSON::MaybeXS qw( decode_json );
 use Text::Table::Tiny qw( generate_table );
 use Text::ASCIITable;
@@ -40,17 +41,14 @@ my $file_mtime;
 # If $file exists then get mtime.
 if ( -e $file ) {
     my $file_stat = path($file)->stat;
-    $file_mtime = DateTime->from_epoch(
-        epoch => $file_stat->[9],
-        time_zone => 'Asia/Kolkata',
-        );
+    $file_mtime = Time::Moment->from_epoch( $file_stat->[9] );
 }
 
 # Fetch latest data only if the local data is older than 8 minutes or
 # if the file doesn't exist.
 if ( ( not -e $file ) or
      ( $file_mtime <
-       DateTime->now( time_zone => 'Asia/Kolkata' )->subtract( minutes => 8 ) ) ) {
+       Time::Moment->now_utc->minus_minutes(8) ) ) {
     require File::Fetch;
 
     # Fetch latest data from api.