Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Not deprecated

Manav Rathi0a3182be5387
diff --git a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
index 25ce1d61b1..d724274640 100644
--- a/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
+++ b/web/apps/photos/src/components/PhotoViewer/FileInfo/index.tsx
@@ -383,13 +383,15 @@ export const CreationTime: React.FC<CreationTimeProps> = ({
// [Note: Don't modify offsetTime when editing date via picker]
//
// Use the updated date time (both in its canonical dateTime
- // form, and also as the legacy timestamp). But don't use the
- // offset. The offset here will be the offset of the computer
- // where this user is making this edit, not the offset of the
- // place where the photo was taken. In a future iteration of the
- // date time editor, we can provide functionality for the user
- // to edit the associated offset, but right now it is not even
- // surfaced, so don't also potentially overwrite it.
+ // form, and also as in the epoch timestamp), but don't use the
+ // offset.
+ //
+ // The offset here will be the offset of the computer where this
+ // user is making this edit, not the offset of the place where
+ // the photo was taken. In a future iteration of the date time
+ // editor, we can provide functionality for the user to edit the
+ // associated offset, but right now it is not even surfaced, so
+ // don't also potentially overwrite it.
const { dateTime, timestamp } = pickedTime;
if (timestamp == originalDate.getTime()) {
// Same as before.
diff --git a/web/apps/photos/src/services/upload/takeout.ts b/web/apps/photos/src/services/upload/takeout.ts
index cdb2880d8f..f0d97b2161 100644
--- a/web/apps/photos/src/services/upload/takeout.ts
+++ b/web/apps/photos/src/services/upload/takeout.ts
@@ -114,26 +114,29 @@ const parseMetadataJSONText = (text: string) => {
const parsedMetadataJSON = { ...NULL_PARSED_METADATA_JSON };
+ // The metadata provided by Google does not include the time zone where the
+ // photo was taken, it only has an epoch seconds value.
if (
metadataJSON["photoTakenTime"] &&
metadataJSON["photoTakenTime"]["timestamp"]
) {
parsedMetadataJSON.creationTime =
- metadataJSON["photoTakenTime"]["timestamp"] * 1000000;
+ metadataJSON["photoTakenTime"]["timestamp"] * 1e6;
} else if (
metadataJSON["creationTime"] &&
metadataJSON["creationTime"]["timestamp"]
) {
parsedMetadataJSON.creationTime =
- metadataJSON["creationTime"]["timestamp"] * 1000000;
+ metadataJSON["creationTime"]["timestamp"] * 1e6;
}
if (
metadataJSON["modificationTime"] &&
metadataJSON["modificationTime"]["timestamp"]
) {
parsedMetadataJSON.modificationTime =
- metadataJSON["modificationTime"]["timestamp"] * 1000000;
+ metadataJSON["modificationTime"]["timestamp"] * 1e6;
}
+
let locationData: Location = { ...NULL_LOCATION };
if (
metadataJSON["geoData"] &&
diff --git a/web/packages/media/file-metadata.ts b/web/packages/media/file-metadata.ts
index a58202819b..3e75dac66f 100644
--- a/web/packages/media/file-metadata.ts
+++ b/web/packages/media/file-metadata.ts
@@ -636,10 +636,11 @@ export interface ParsedMetadata {
* offset, its siblings photos might not. The only way to retain their
* comparability is to treat them all the "time zone where the photo was taken".
*
- * Finally, while this is all great, we still have existing code that deals with
- * UTC timestamps. So we also retain the existing `creationTime` UTC timestamp,
- * but this should be considered deprecated, and over time we should move
- * towards using the `dateTime` string.
+ * All this is good, but we still need to retain the existing `creationTime` UTC
+ * epoch timestamp because in some cases when importing photos from other
+ * providers, that's all we get. We could try and convert that to a date/time
+ * string too, but since we anyways need to handle existing code that deals with
+ * epoch timestamps, we retain them as they were provided.
*/
export interface ParsedMetadataDate {
/**
@@ -760,8 +761,9 @@ export const parseMetadataDate = (
const dropLast = (s: string) => (s ? s.substring(0, s.length - 1) : s);
/**
- * Return a date that can be used on the UI from a {@link ParsedMetadataDate},
- * or its {@link dateTime} component, or the legacy epoch timestamps.
+ * Return a date that can be used on the UI by constructing it from a
+ * {@link ParsedMetadataDate}, or its {@link dateTime} component, or a UTC epoch
+ * timestamp.
*
* These dates are all hypothetically in the timezone of the place where the
* photo was taken. Different photos might've been taken in different timezones,
@@ -791,7 +793,7 @@ export const toUIDate = (dateLike: ParsedMetadataDate | string | number) => {
// `ParsedMetadataDate.dateTime`.
return new Date(dateLike);
case "number":
- // A legacy epoch microseconds value.
+ // A UTC epoch microseconds value.
return new Date(dateLike / 1000);
}
};