6 namespace org { namespace ldk { namespace structs {
10 * A timestamp that refers to a date after 1 January 1970.
14 * The Unix timestamp representing the stored time has to be positive and no greater than
17 public class PositiveTimestamp : CommonBase {
18 internal PositiveTimestamp(object _dummy, long ptr) : base(ptr) { }
19 ~PositiveTimestamp() {
20 if (ptr != 0) { bindings.PositiveTimestamp_free(ptr); }
24 * Checks if two PositiveTimestamps contain equal inner contents.
25 * This ignores pointers and is_owned flags and looks at the values in fields.
26 * Two objects with NULL inner values will be considered "equal" here.
28 public bool eq(org.ldk.structs.PositiveTimestamp b) {
29 bool ret = bindings.PositiveTimestamp_eq(this.ptr, b == null ? 0 : b.ptr);
32 if (this != null) { this.ptrs_to.AddLast(b); };
36 public override bool Equals(object o) {
37 if (!(o is PositiveTimestamp)) return false;
38 return this.eq((PositiveTimestamp)o);
40 internal long clone_ptr() {
41 long ret = bindings.PositiveTimestamp_clone_ptr(this.ptr);
47 * Creates a copy of the PositiveTimestamp
49 public PositiveTimestamp clone() {
50 long ret = bindings.PositiveTimestamp_clone(this.ptr);
52 if (ret >= 0 && ret <= 4096) { return null; }
53 org.ldk.structs.PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PositiveTimestamp(null, ret); }
54 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(this); };
59 * Checks if two PositiveTimestamps contain equal inner contents.
62 long ret = bindings.PositiveTimestamp_hash(this.ptr);
67 public override int GetHashCode() {
68 return (int)this.hash();
71 * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`.
73 * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
75 public static Result_PositiveTimestampCreationErrorZ from_unix_timestamp(long unix_seconds) {
76 long ret = bindings.PositiveTimestamp_from_unix_timestamp(unix_seconds);
77 GC.KeepAlive(unix_seconds);
78 if (ret >= 0 && ret <= 4096) { return null; }
79 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
84 * Creates a `PositiveTimestamp` from a [`SystemTime`] with a corresponding Unix timestamp in
85 * the range `0..=MAX_TIMESTAMP`.
87 * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
89 * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
91 public static Result_PositiveTimestampCreationErrorZ from_system_time(long time) {
92 long ret = bindings.PositiveTimestamp_from_system_time(time);
94 if (ret >= 0 && ret <= 4096) { return null; }
95 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
100 * Creates a `PositiveTimestamp` from a [`Duration`] since the Unix epoch in the range
101 * `0..=MAX_TIMESTAMP`.
103 * Note that the subsecond part is dropped as it is not representable in BOLT 11 invoices.
105 * Otherwise, returns a [`CreationError::TimestampOutOfBounds`].
107 public static Result_PositiveTimestampCreationErrorZ from_duration_since_epoch(long duration) {
108 long ret = bindings.PositiveTimestamp_from_duration_since_epoch(duration);
109 GC.KeepAlive(duration);
110 if (ret >= 0 && ret <= 4096) { return null; }
111 Result_PositiveTimestampCreationErrorZ ret_hu_conv = Result_PositiveTimestampCreationErrorZ.constr_from_ptr(ret);
116 * Returns the Unix timestamp representing the stored time
118 public long as_unix_timestamp() {
119 long ret = bindings.PositiveTimestamp_as_unix_timestamp(this.ptr);
125 * Returns the duration of the stored time since the Unix epoch
127 public long as_duration_since_epoch() {
128 long ret = bindings.PositiveTimestamp_as_duration_since_epoch(this.ptr);
134 * Returns the [`SystemTime`] representing the stored time
136 public long as_time() {
137 long ret = bindings.PositiveTimestamp_as_time(this.ptr);