Debian Codegraph @

html/Shift.html

raw symbols SCIP
1 <?xml version="1.0" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4 <head>
5 <title>ExifTool Date/Time Shift Module</title>
6 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7 <link rev="made" href="mailto:[email protected]" />
8 <style type='text/css'><!-- pre { margin-left: 2em } --></style></head>
9
10 <body>
11 <table border="0" width="100%" cellspacing="0" cellpadding="3">
12 <tr><td class="_podblock_" style="background-color: #cccccc; color: #000" valign="middle">
13 <big><strong><span class="_podblock_">&nbsp;ExifTool Date/Time Shift Module</span></strong></big>
14 </td></tr>
15 </table>
16
17
18
19 <ul id="index">
20 <li><a href="#NAME">NAME</a></li>
21 <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
22 <li><a href="#METHODS">METHODS</a>
23 <ul>
24 <li><a href="#ShiftTime">ShiftTime</a></li>
25 </ul>
26 </li>
27 <li><a href="#SHIFT-STRING">SHIFT STRING</a></li>
28 <li><a href="#NOTES">NOTES</a></li>
29 <li><a href="#TRICKY">TRICKY</a></li>
30 <li><a href="#BUGS">BUGS</a></li>
31 <li><a href="#AUTHOR">AUTHOR</a></li>
32 <li><a href="#SEE-ALSO">SEE ALSO</a></li>
33 </ul>
34
35 <h1 id="NAME">NAME</h1>
36
37 <p>Image::ExifTool::Shift.pl - ExifTool time shifting routines</p>
38
39 <h1 id="DESCRIPTION">DESCRIPTION</h1>
40
41 <p>This module contains routines used by ExifTool to shift date and time values.</p>
42
43 <h1 id="METHODS">METHODS</h1>
44
45 <h2 id="ShiftTime">ShiftTime</h2>
46
47 <p>Shift date/time value</p>
48
49 <pre><code>use Image::ExifTool;
50 $err = Image::ExifTool::ShiftTime($dateTime, $shift);</code></pre>
51
52 <dl>
53
54 <dt id="Inputs">Inputs:</dt>
55 <dd>
56
57 <p>0) Date/time string in EXIF format (eg. <code>2016:01:30 11:45:00</code>).</p>
58
59 <p>1) Shift string (see below) with optional leading sign for shift direction.</p>
60
61 <p>2) [optional] Direction of shift (-1 or +1), or 0 or undef to use the sign from the shift string.</p>
62
63 <p>3) [optional] Reference to time-shift hash -- filled in by first call to <b>ShiftTime</b>, and used in subsequent calls to shift date/time values by the same relative amount (see <a href="#TRICKY">&quot;TRICKY&quot;</a> section below).</p>
64
65 <p>or</p>
66
67 <p>0) Shift string (and $_ contains the input date/time string).</p>
68
69 </dd>
70 <dt id="Return-value">Return value:</dt>
71 <dd>
72
73 <p>Error string, or undef on success and the input date/time string is shifted by the specified amount.</p>
74
75 </dd>
76 </dl>
77
78 <h1 id="SHIFT-STRING">SHIFT STRING</h1>
79
80 <p>Time shifts are applied to standard EXIF-formatted date/time values (eg. <code>2005:03:14 18:55:00</code>). Date-only and time-only values may also be shifted, and an optional timezone (eg. <code>-05:00</code>) is also supported. Here are some general rules and examples to explain how shift strings are interpreted:</p>
81
82 <p>Date-only values are shifted using the following formats:</p>
83
84 <pre><code>&#39;Y:M:D&#39; - shift date by &#39;Y&#39; years, &#39;M&#39; months and &#39;D&#39; days
85 &#39;M:D&#39; - shift months and days only
86 &#39;D&#39; - shift specified number of days</code></pre>
87
88 <p>Time-only values are shifted using the following formats:</p>
89
90 <pre><code>&#39;h:m:s&#39; - shift time by &#39;h&#39; hours, &#39;m&#39; minutes and &#39;s&#39; seconds
91 &#39;h:m&#39; - shift hours and minutes only
92 &#39;h&#39; - shift specified number of hours</code></pre>
93
94 <p>Timezone shifts are specified in the following formats:</p>
95
96 <pre><code>&#39;+h:m&#39; - shift timezone by &#39;h&#39; hours and &#39;m&#39; minutes
97 &#39;-h:m&#39; - negative shift of timezone hours and minutes
98 &#39;+h&#39; - shift timezone hours only
99 &#39;-h&#39; - negative shift of timezone hours only</code></pre>
100
101 <p>A valid shift value consists of one or two arguments, separated by a space. If only one is provided, it is assumed to be a time shift when applied to a time-only or a date/time value, or a date shift when applied to a date-only value. For example:</p>
102
103 <pre><code>&#39;1&#39; - shift by 1 hour if applied to a time or date/time
104 value, or by one day if applied to a date value
105 &#39;2:0&#39; - shift 2 hours (time, date/time), or 2 months (date)
106 &#39;5:0:0&#39; - shift 5 hours (time, date/time), or 5 years (date)
107 &#39;0:0:1&#39; - shift 1 s (time, date/time), or 1 day (date)</code></pre>
108
109 <p>If two arguments are given, the date shift is first, followed by the time shift:</p>
110
111 <pre><code>&#39;3:0:0 0&#39; - shift date by 3 years
112 &#39;0 15:30&#39; - shift time by 15 hours and 30 minutes
113 &#39;1:0:0 0:0:0+5:0&#39; - shift date by 1 year and timezone by 5 hours</code></pre>
114
115 <p>A date shift is simply ignored if applied to a time value or visa versa.</p>
116
117 <p>Numbers specified in shift fields may contain a decimal point:</p>
118
119 <pre><code>&#39;1.5&#39; - 1 hour 30 minutes (time, date/time), or 1 day (date)
120 &#39;2.5 0&#39; - 2 days 12 hours (date/time), 12 hours (time) or
121 2 days (date)</code></pre>
122
123 <p>And to save typing, a zero is assumed for any missing numbers:</p>
124
125 <pre><code>&#39;1::&#39; - shift by 1 hour (time, date/time) or 1 year (date)
126 &#39;26:: 0&#39; - shift date by 26 years
127 &#39;+:30&#39; - shift timezone by 30 minutes</code></pre>
128
129 <p>Below are some specific examples applied to real date and/or time values (&#39;Dir&#39; is the applied shift direction: &#39;+&#39; is positive, &#39;-&#39; is negative):</p>
130
131 <pre><code> Original Value Shift Dir Shifted Value
132 --------------------- ------- --- ---------------------
133 &#39;20:30:00&#39; &#39;5&#39; + &#39;01:30:00&#39;
134 &#39;2005:01:27&#39; &#39;5&#39; + &#39;2005:02:01&#39;
135 &#39;2005:01:27 20:30:00&#39; &#39;5&#39; + &#39;2005:01:28 01:30:00&#39;
136 &#39;11:54:00&#39; &#39;2.5 0&#39; - &#39;23:54:00&#39;
137 &#39;2005:11:02&#39; &#39;2.5 0&#39; - &#39;2005:10:31&#39;
138 &#39;2005:11:02 11:54:00&#39; &#39;2.5 0&#39; - &#39;2005:10:30 23:54:00&#39;
139 &#39;2004:02:28 08:00:00&#39; &#39;1 1.3&#39; + &#39;2004:02:29 09:18:00&#39;
140 &#39;07:00:00&#39; &#39;-5&#39; + &#39;07:00:00&#39;
141 &#39;07:00:00+01:00&#39; &#39;-5&#39; + &#39;07:00:00-04:00&#39;
142 &#39;07:00:00Z&#39; &#39;+2:30&#39; - &#39;07:00:00-02:30&#39;
143 &#39;1970:01:01&#39; &#39;35::&#39; + &#39;2005:01:01&#39;
144 &#39;2005:01:01&#39; &#39;400&#39; + &#39;2006:02:05&#39;
145 &#39;10:00:00.00&#39; &#39;::1.33&#39; - &#39;09:59:58.67&#39;</code></pre>
146
147 <h1 id="NOTES">NOTES</h1>
148
149 <p>The format of the original date/time value is not changed when the time shift is applied. This means that the length of the date/time string will not change, and only the numbers in the string will be modified. The only exception to this rule is that a &#39;Z&#39; timezone is changed to &#39;+00:00&#39; notation if a timezone shift is applied. A timezone will not be added to the date/time string.</p>
150
151 <h1 id="TRICKY">TRICKY</h1>
152
153 <p>This module is perhaps more complicated than it needs to be because it is designed to be very flexible in the way time shifts are specified and applied...</p>
154
155 <p>The ability to shift dates by Y years, M months, etc, conflicts with the design goal of maintaining a constant shift for all time values when applying a batch shift. This is because shifting by 1 month can be equivalent to anything from 28 to 31 days, and 1 year can be 365 or 366 days, depending on the starting date.</p>
156
157 <p>The inconsistency is handled by shifting the first tag found with the actual specified shift, then calculating the equivalent time difference in seconds for this shift and applying this difference to subsequent tags in a batch conversion. So if it works as designed, the behaviour should be both intuitive and mathematically correct, and the user shouldn&#39;t have to worry about details such as this (in keeping with Perl&#39;s &quot;do the right thing&quot; philosophy).</p>
158
159 <h1 id="BUGS">BUGS</h1>
160
161 <p>Due to the use of the standard time library functions, dates are typically limited to the range 1970 to 2038 on 32-bit systems.</p>
162
163 <h1 id="AUTHOR">AUTHOR</h1>
164
165 <p>Copyright 2003-2026, Phil Harvey (philharvey66 at gmail.com)</p>
166
167 <p>This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.</p>
168
169 <h1 id="SEE-ALSO">SEE ALSO</h1>
170
171 <p><a>Image::ExifTool(3pm)</a></p>
172
173 <table border="0" width="100%" cellspacing="0" cellpadding="3">
174 <tr><td class="_podblock_" style="background-color: #cccccc; color: #000" valign="middle">
175 <big><strong><span class="_podblock_">&nbsp;ExifTool Date/Time Shift Module</span></strong></big>
176 </td></tr>
177 </table>
178
179 </body>
180
181 </html>
182
183