1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2026 Innovation Trigger B.V.
//
// PDFluent is available under two licences, at your option: the GNU AGPLv3, or
// the PDFluent Commercial Licence. See the LICENSE file in this repository --
// that file travels with the copy you received, which a URL does not.
//! Wall-clock time that works on every target we ship to.
//!
//! # Why this exists
//!
//! `std::time::SystemTime::now()` is not implemented on
//! `wasm32-unknown-unknown`. It compiles — against the `unsupported` stub in
//! std — and then **panics at runtime** with "time not implemented on this
//! platform". Under the release profile's `panic = "abort"` that surfaces to
//! JavaScript as a bare `RuntimeError: unreachable`, with no message and no
//! location.
//!
//! That is not hypothetical: it took down `PdfDoc.convertToPdfa` for every
//! input and every conformance level in the browser build, because PDF/A
//! conversion always embeds fonts and the embedding path timestamps its
//! licence check. Native builds were unaffected throughout, so the whole
//! native test suite stayed green while the WASM binding was completely
//! broken.
//!
//! Anything in this workspace that needs the current time must go through
//! here rather than calling `SystemTime` directly.
/// Seconds since the Unix epoch.
///
/// Returns 0 rather than panicking if the platform clock is unavailable or
/// reports a time before the epoch. Callers use this for licence validity
/// windows and document timestamps, where a wrong-but-present value degrades
/// gracefully and a panic does not.