Add option --mssafe to isodate

MS OSs don't like ":" in filenames (and Samba's scrambling algorithm
makes filenames with it completely unrecognizable), so I added an option
to use a less dangerous character ("-") in the time part. "." would
have been nicer and technically possible but that's used to delimit
extensions, so that might have had surprising consequences, too. Just
omitting the delimiter and squashing HHMMSS together isn't very
readable.
This commit is contained in:
Peter J. Holzer 2016-10-04 23:21:58 +02:00
parent be21bc6ff8
commit 2209823843
1 changed files with 14 additions and 2 deletions

View File

@ -1,2 +1,14 @@
#!/bin/sh #!/usr/bin/perl
date '+%Y-%m-%dT%H:%M:%S' use v5.10;
use warnings;
use strict;
use Getopt::Long;
use POSIX qw(strftime);
use Pod::Usage;
my $mssafe;
GetOptions(
"mssafe" => \$mssafe
) or pod2usage(1);
my $fmt = $mssafe ? "%Y-%m-%dT%H-%M-%S" : "%Y-%m-%dT%H:%M:%S";
say strftime($fmt, localtime);