about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rwxr-xr-xleo.pl15
-rw-r--r--share/config.pl1
2 files changed, 10 insertions, 6 deletions
diff --git a/leo.pl b/leo.pl
index fcf3bef..dcb8447 100755
--- a/leo.pl
+++ b/leo.pl
@@ -19,18 +19,20 @@ GetOptions(
     qw{ verbose encrypt sign delete help }
 ) or die "Error in command line arguments\n";
 
-my $ymd = ymd(); # YYYY-MM-DD.
-my $backup_dir = "/tmp/backups/$ymd";
-
-path($backup_dir)->mkpath; # Create backup directory.
-my $prof;
-
 # Config file for leo.
 my $config_file = $ENV{XDG_CONFIG_HOME} || "$ENV{HOME}/.config";
 $config_file .= "/leo.pl";
 
 require "$config_file";
 
+my $ymd = ymd(); # YYYY-MM-DD.
+my $backup_dir = get_backup_dir() || "/tmp/backups";
+$backup_dir .= "/$ymd";
+
+path($backup_dir)->mkpath; # Create backup directory.
+my $prof;
+
+
 my %profile = get_profile();
 my $gpg_fingerprint = get_gpg_fingerprint();
 my $gpg_bin = get_gpg_bin();
@@ -145,5 +147,6 @@ sub ymd {
     my @months = qw( 01 02 03 04 05 06 07 08 09 10 11 12 );
     my $month = $months[$mon];
 
+    $mday = sprintf "%02d", $mday;
     return "$year-$month-$mday";
 }
diff --git a/share/config.pl b/share/config.pl
index caee891..7d542f3 100644
--- a/share/config.pl
+++ b/share/config.pl
@@ -31,5 +31,6 @@ $profile{mozilla} = $profile{".mozilla"};
 sub get_gpg_fingerprint { return $gpg_fingerprint; }
 sub get_profile { return %profile; }
 sub get_gpg_bin { return $gpg_bin; }
+sub get_backup_dir { return "/tmp/backups" }
 
 1;