Merge pull request #1183 from Exiv2/fix_1180_date_separator

fix_1180_date_separator (0.27->master)
This commit is contained in:
Robin Mills
2020-04-26 12:45:12 +01:00
committed by GitHub
6 changed files with 65 additions and 2 deletions
+14 -1
View File
@@ -2,7 +2,7 @@
.\" First parameter, NAME, should be all caps
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
.\" other parameters are allowed: see man(7), man(1)
.TH EXIV2 1 "March 28, 2020"
.TH EXIV2 1 "April 25, 2020"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
@@ -271,12 +271,14 @@ options.
Set the file timestamp according to the Exif create timestamp in
addition to renaming the file (overrides \fB\-k\fP). This option is
only used with the 'rename' action.
See Exif DateTime below for additional information.
.TP
.B \-T
Only set the file timestamp according to the Exif create timestamp, do
not rename the file (overrides \fB\-k\fP). This option is only used
with the 'rename' action. Note: On Windows you may have to set the TZ
environment variable for this option to work correctly.
See Exif DateTime below for additional information.
.TP
.B \-f,\-F
These options are used by the commands 'rename' and 'extract' to
@@ -327,6 +329,7 @@ Default filename format is %Y%m%d_%H%M%S.
Time adjustment in the format [\-]HH[:MM[:SS]]. This option is only
used with the 'adjust' action. Examples: 1 adds one hour, 1:01
adds one hour and one minute, \-0:00:30 subtracts 30 seconds.
See Exif DateTime below for additional information.
.TP
.B \-Y \fIyrs\fP
Time adjustment by a positive or negative number of years, for
@@ -622,6 +625,16 @@ To register additional XMP namespaces, combine the command with:
.nf
\fBreg\fP \fIprefix\fP \fInamespace\fP
.br
.SS Exif DateTime
.fi
An Exif DateTime string is stored as 20 ascii bytes (including trailing nul) in the format:
.sp 1
YYYY:MM:DD HH:MM:SS
.sp 1
The exiv2 command-line program options -t and -T will accept files
in which the Date has been incorrectly stored as YYYY-MM-DD.
The option -a enables the user to adjust the DateTime in the file and applies
the YYYY:MM:DD HH:MM:SS standard.
.ne 4
.fi
.SS Command file format
+1 -1
View File
@@ -1971,7 +1971,7 @@ namespace {
{
if (timeStr.length() == 0 || timeStr[0] == ' ') return 1;
if (timeStr.length() < 19) return 2;
if ( timeStr[4] != ':' || timeStr[7] != ':' || timeStr[10] != ' '
if ( (timeStr[4] != ':' && timeStr[4] != '-') || (timeStr[7] != ':' && timeStr[7] != '-') || timeStr[10] != ' '
|| timeStr[13] != ':' || timeStr[16] != ':') return 3;
if (0 == tm) return 4;
std::memset(tm, 0x0, sizeof(struct tm));
Binary file not shown.
+28
View File
@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*-
from system_tests import CaseMeta, CopyTmpFiles, path
@CopyTmpFiles("$data_path/test_issue_1180.exv")
class test_issue_1180Test(metaclass=CaseMeta):
filename = path("$tmp_path/test_issue_1180.exv")
dash_t = path("$tmp_path/20200424_174415.exv") # -t renames file
dash_T = path("$tmp_path/20200424_154415.exv") # -T renames file
commands = [ "$exiv2 -K Exif.Image.DateTime $filename"
, "$exiv2 -t --force $filename"
, "$exiv2 -K Exif.Image.DateTime $dash_t"
, "$exiv2 -a -02:00 --force $dash_t"
, "$exiv2 -K Exif.Image.DateTime $dash_t"
, "$exiv2 -t --force $dash_t"
, "$exiv2 -K Exif.Image.DateTime $dash_T"
]
stdout = ["Exif.Image.DateTime Ascii 50 2020-04-24 17:44:15 \n"
,""
,"Exif.Image.DateTime Ascii 50 2020-04-24 17:44:15 \n"
,""
,"Exif.Image.DateTime Ascii 20 2020:04:24 15:44:15\n"
,""
,"Exif.Image.DateTime Ascii 20 2020:04:24 15:44:15\n"
]
stderr = [""]*len(commands)
retval = [ 0]*len(commands)
+1
View File
@@ -14,6 +14,7 @@ exiv2_path: ../build/bin
exiv2: ${ENV:exiv2_path}/exiv2${ENV:binary_extension}
exiv2json: ${ENV:exiv2_path}/exiv2json${ENV:binary_extension}
data_path: ../test/data
tmp_path: ../test/tmp
tiff_test: ${ENV:exiv2_path}/tiff-test${ENV:binary_extension}
largeiptc_test: ${ENV:exiv2_path}/largeiptc-test${ENV:binary_extension}
easyaccess_test: ${ENV:exiv2_path}/easyaccess-test${ENV:binary_extension}
+21
View File
@@ -169,6 +169,8 @@ def configure_suite(config_file):
abs_path = os.path.abspath(
os.path.join(_parameters["suite_root"], rel_path)
)
if key == "tmp_path" and not os.path.isdir(abs_path):
os.mkdir(abs_path)
if not os.path.exists(abs_path):
raise ValueError(
"Path replacement for {short}: {abspath} does not exist"
@@ -460,7 +462,26 @@ class CopyFiles(FileDecoratorBase):
fname, ext = os.path.splitext(expanded_file_name)
new_name = fname + '_copy' + ext
return shutil.copyfile(expanded_file_name, new_name)
class CopyTmpFiles(FileDecoratorBase):
"""
This class copies files from test/data to test/tmp
Copied files are NOT removed in tearDown
Example: @CopyTmpFiles("$data_path/test_issue_1180.exv")
"""
#: override the name of the file list
FILE_LIST_NAME = '_tmp_files'
def setUp_file_action(self, expanded_file_name):
tmp_path = _config_variables['tmp_path']
tmp_name = os.path.join(tmp_path,os.path.basename(expanded_file_name))
return shutil.copyfile(expanded_file_name, tmp_name)
def tearDown_file_action(self, f):
"""
Do nothing. We don't clean up TmpFiles
"""
class DeleteFiles(FileDecoratorBase):
"""