Skip to content

Commit f687359

Browse files
Fix incorrect asset date when viewing restored data offline
Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
1 parent 62177e8 commit f687359

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
1. Fix incorrect asset date display when viewing restored data offline [#3336](https://github.com/numbersprotocol/capture-lite/issues/3336)
13+
1014
## [0.101.1] - 2025-03-21
1115

1216
### Fixed

src/app/shared/repositories/proof/proof.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,12 @@ export class Proof {
6161
*/
6262
get uploadedAtOrTimestamp() {
6363
const MILLISECONDS_PER_SECOND = 1000;
64-
const LENGTH_IN_MILLISECONDS = 13;
64+
const MILLISECONDS_THRESHOLD = 10000000000; // 10^10, timestamps after March 2001
6565

6666
// convert timestamp to milliseconds if needed
67+
// Use threshold-based approach instead of string length to determine if timestamp is in milliseconds
6768
const proofTimestampInMilliseconds =
68-
this.timestamp.toString().length === LENGTH_IN_MILLISECONDS
69+
this.timestamp > MILLISECONDS_THRESHOLD
6970
? this.timestamp
7071
: this.timestamp * MILLISECONDS_PER_SECOND;
7172

@@ -80,7 +81,8 @@ export class Proof {
8081
* Note: After restoring or syncing with the backend assets, the timestamp will be in seconds.
8182
* For more details, refer to https://github.com/numbersprotocol/storage-backend/issues/976
8283
*
83-
* Note: Milliseconds are 13 digits long, while seconds are 10 digits long.
84+
* Note: Milliseconds are typically 13 digits long (after 2001), while seconds are typically 10 digits long.
85+
* We use a threshold-based approach to detect and convert between these formats.
8486
*/
8587
get timestamp() {
8688
return this.truth.timestamp;

0 commit comments

Comments
 (0)