exiftool-vendored
Advanced tools
Comparing version 2.16.1 to 2.17.0
@@ -6,6 +6,6 @@ export declare function compact<T>(array: (T | undefined | null)[]): T[]; | ||
* | ||
* @param millis [0-1000) | ||
* @param millis [0,1000) | ||
* @return the decimal fraction of the second (to maximally microsecond precision) | ||
*/ | ||
export declare function millisToFractionalPart(millis: number): string; | ||
export declare function millisToFractionalPart(millis: number, precision?: number): string; | ||
export declare abstract class Base { | ||
@@ -25,3 +25,3 @@ protected tz(tzoffsetMinutes: number | undefined): string; | ||
/** | ||
* @param hour [1-23] | ||
* @param hour [1, 23] | ||
* @param minute [0, 59] | ||
@@ -84,3 +84,3 @@ * @param second [0, 59] | ||
toString(): string; | ||
toISOString(): string; | ||
toISOString(millisPrecision?: number): string; | ||
} | ||
@@ -87,0 +87,0 @@ export declare class ExifTimeZoneOffset extends Base { |
@@ -46,7 +46,8 @@ "use strict"; | ||
* | ||
* @param millis [0-1000) | ||
* @param millis [0,1000) | ||
* @return the decimal fraction of the second (to maximally microsecond precision) | ||
*/ | ||
function millisToFractionalPart(millis) { | ||
var frac = (millis / 1000).toPrecision(6).split("").slice(1); // pop off the "0." bit | ||
function millisToFractionalPart(millis, precision) { | ||
if (precision === void 0) { precision = 6; } | ||
var frac = (millis / 1000).toPrecision(precision).split("").slice(1); // pop off the initial "0" | ||
// strip off microsecond zero padding: | ||
@@ -98,3 +99,3 @@ while (frac.length > 4 && frac[frac.length - 1] === "0") { | ||
/** | ||
* @param hour [1-23] | ||
* @param hour [1, 23] | ||
* @param minute [0, 59] | ||
@@ -191,6 +192,6 @@ * @param second [0, 59] | ||
ExifDateTime.prototype.toDate = function () { | ||
if (this.tzoffsetMinutes === undefined) { | ||
if (this.tzoffsetMinutes == null) { | ||
var d = new Date(); | ||
d.setFullYear(this.year, this.month - 1, this.day); | ||
d.setHours(this.hour, this.minute, this.second); | ||
d.setHours(this.hour, this.minute, this.second, Math.round(this.millis)); | ||
return d; | ||
@@ -200,6 +201,7 @@ } | ||
// Don't leave it up to string parsing | ||
return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millis)); | ||
return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millis // << Date seems to handle floats, so no need to round. | ||
)); | ||
} | ||
else { | ||
return new Date(this.toISOString()); | ||
return new Date(this.toISOString(3)); | ||
} | ||
@@ -210,5 +212,6 @@ }; | ||
}; | ||
ExifDateTime.prototype.toISOString = function () { | ||
ExifDateTime.prototype.toISOString = function (millisPrecision) { | ||
if (millisPrecision === void 0) { millisPrecision = 6; } | ||
var _a = pad2(this.month, this.day, this.hour, this.minute, this.second), mo = _a[0], da = _a[1], ho = _a[2], mi = _a[3], se = _a[4]; | ||
return this.year + "-" + mo + "-" + da + "T" + ho + ":" + mi + ":" + se + millisToFractionalPart(this.millis) + this.tz(this.tzoffsetMinutes); | ||
return this.year + "-" + mo + "-" + da + "T" + ho + ":" + mi + ":" + se + millisToFractionalPart(this.millis, millisPrecision) + this.tz(this.tzoffsetMinutes); | ||
}; | ||
@@ -215,0 +218,0 @@ return ExifDateTime; |
{ | ||
"name": "exiftool-vendored", | ||
"version": "2.16.1", | ||
"version": "2.17.0", | ||
"description": "Efficient, cross-platform access to ExifTool", | ||
@@ -5,0 +5,0 @@ "main": "./dist/exiftool.js", |
@@ -201,2 +201,8 @@ # exiftool-vendored | ||
### v2.17 | ||
* 🐛 Rounded milliseconds were not set by `ExifDateTime.toDate()` when timezone | ||
was not available. Breaking tests were added. | ||
### v2.16.1 | ||
@@ -203,0 +209,0 @@ |
163691
4171
371