@@ -58,19 +58,12 @@ export class Proof {
5858
5959 /**
6060 * Used to sort the assets in the VERIFIED tab either by timestamp or uploadedAt (if available).
61+ * Since timestamp getter now ensures values are always in milliseconds, we don't need
62+ * to perform the seconds-to-milliseconds conversion here.
6163 */
6264 get uploadedAtOrTimestamp ( ) {
63- const MILLISECONDS_PER_SECOND = 1000 ;
64- const LENGTH_IN_MILLISECONDS = 13 ;
65-
66- // convert timestamp to milliseconds if needed
67- const proofTimestampInMilliseconds =
68- this . timestamp . toString ( ) . length === LENGTH_IN_MILLISECONDS
69- ? this . timestamp
70- : this . timestamp * MILLISECONDS_PER_SECOND ;
71-
7265 const serverTimestampInMilliseconds = Date . parse ( this . uploadedAt ?? '' ) ;
73- return serverTimestampInMilliseconds || proofTimestampInMilliseconds ;
66+ return serverTimestampInMilliseconds || this . timestamp ;
7467 }
7568
7669 /**
@@ -80,10 +73,21 @@ export class Proof {
8073 * Note: After restoring or syncing with the backend assets, the timestamp will be in seconds.
8174 * For more details, refer to https://github.com/numbersprotocol/storage-backend/issues/976
8275 *
83- * Note: Milliseconds are 13 digits long, while seconds are 10 digits long.
76+ * Note: Milliseconds are typically 13 digits long (after 2001), while seconds are
77+ * typically 10 digits long.
78+ * We use a threshold-based approach to detect and convert between these formats.
79+ *
80+ * This getter ensures timestamps are always returned in milliseconds regardless of
81+ * how they're stored (seconds or milliseconds).
8482 */
8583 get timestamp ( ) {
86- return this . truth . timestamp ;
84+ const MILLISECONDS_PER_SECOND = 1000 ;
85+ const MILLISECONDS_THRESHOLD = 10000000000 ; // 10^10, timestamps after March 2001
86+
87+ // Convert to milliseconds if the timestamp is in seconds
88+ return this . truth . timestamp > MILLISECONDS_THRESHOLD
89+ ? this . truth . timestamp
90+ : this . truth . timestamp * MILLISECONDS_PER_SECOND ;
8791 }
8892
8993 get deviceName ( ) {
0 commit comments