From 2209823843e0696f3318dc46c1dd9b7bcfaf09db Mon Sep 17 00:00:00 2001 From: "Peter J. Holzer" Date: Tue, 4 Oct 2016 23:21:58 +0200 Subject: [PATCH] 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. --- tiny/isodate | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tiny/isodate b/tiny/isodate index 0cf1c0d..3b3ec13 100755 --- a/tiny/isodate +++ b/tiny/isodate @@ -1,2 +1,14 @@ -#!/bin/sh -date '+%Y-%m-%dT%H:%M:%S' +#!/usr/bin/perl +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);