about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-05-29 20:42:07 +0530
committerAndinus <andinus@nand.sh>2020-05-29 20:42:07 +0530
commit569c76adac2d848897e03cfc4d9469f161e7aeae (patch)
treed86c143f708a11892881464172999c2fc0ee9551
parentdaae57a2c2890c37a825a410136fcab62bf14b70 (diff)
downloadara-569c76adac2d848897e03cfc4d9469f161e7aeae.tar.gz
Use $last_update_dmy instead of substr func everywhere
-rwxr-xr-xara.pl7
1 files changed, 4 insertions, 3 deletions
diff --git a/ara.pl b/ara.pl
index 6779d7f..2d2305b 100755
--- a/ara.pl
+++ b/ara.pl
@@ -69,14 +69,15 @@ my $today = DateTime->now( time_zone => 'UTC' );
 foreach my $i (0...37) {
     my $update_info;
     my $lastupdatedtime = $statewise[0][$i]{'lastupdatedtime'};
+    my $last_update_dmy = substr( $lastupdatedtime, 0, 10 );
 
     # Add $update_info.
-    if ( substr( $lastupdatedtime, 0, 10 ) eq $today->dmy('/') ) {
+    if ( $last_update_dmy eq $today->dmy('/') ) {
         $update_info = "Today";
-    } elsif ( substr( $lastupdatedtime, 0, 10 ) eq
+    } elsif ( $last_update_dmy eq
               $today->clone->subtract( days => 1 )->dmy('/') ) {
         $update_info = "Yesterday";
-    } elsif ( substr( $lastupdatedtime, 0, 10 ) eq
+    } elsif ( $last_update_dmy eq
               $today->clone->add( days => 1 )->dmy('/') ) {
         $update_info = "Tomorrow"; # Hopefully we don't see this.
     } else {