@hoox-sh/pynets 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,18 @@ export interface UtcParts {
19
19
  const MIN_T = -62_167_219_200; // ~year 0001
20
20
  const MAX_T = 253_402_300_799; // ~year 9999
21
21
 
22
+ /**
23
+ * Unix seconds (< 1e11) become milliseconds; millisecond stamps pass through.
24
+ * Python `utility._timestamp_to_ms` SoT. Chart hosts often store bar opens
25
+ * in seconds — `hour(time)` divides by 1000, so a seconds stamp collapses
26
+ * a multi-day chart into one clock hour. `null`/`na` stays `null`.
27
+ */
28
+ export function timestampToMs(ts: number | null | undefined): number | null {
29
+ if (ts == null || !Number.isFinite(ts)) return null;
30
+ if (Math.abs(ts) < 1.0e11) return ts * 1000.0;
31
+ return ts;
32
+ }
33
+
22
34
  /** Unix-ms → UTC parts. Matches Python `utc_parts_from_ms`. */
23
35
  export function utcPartsFromMs(ms: number): UtcParts {
24
36
  let t = Number.isFinite(ms) ? Math.trunc(ms / 1000) : 0;