Debug label: Object.prototype.toString reports [object CborDate].
The date as the number of seconds since the Unix epoch
(1970-01-01T00:00:00Z), as a floating-point number. Negative values
represent times before the epoch; the fractional part is sub-second
precision.
StaticcodecStaticfromCreates a new CborDate from the given JavaScript Date.
This method creates a new CborDate instance by wrapping a
JavaScript Date.
A Date instance to wrap
A new CborDate instance
StaticfromCreates a new CborDate from year, month, and day components.
This method creates a new CborDate with the time set to 00:00:00 UTC.
The year component (e.g., 2023)
The month component (1-12)
The day component (1-31)
A new CborDate instance
StaticfromCreates a new CborDate from year, month, day, hour, minute, and second
components.
The year component (e.g., 2023)
The month component (1-12)
The day component (1-31)
The hour component (0-23)
The minute component (0-59)
The second component (0-59)
A new CborDate instance
StaticfromCreates a new CborDate from seconds since (or before) the Unix epoch.
This method creates a new CborDate representing the specified number of
seconds since the Unix epoch (1970-01-01T00:00:00Z). Negative values
represent times before the epoch.
Seconds from the Unix epoch (positive or negative), which can include a fractional part for sub-second precision
A new CborDate instance
StaticfromCreates a new CborDate from a string containing an ISO-8601 (RFC-3339)
date (with or without time).
This method parses a string representation of a date or date-time in
ISO-8601/RFC-3339 format and creates a new CborDate instance. It
supports both full date-time strings (e.g., "2023-02-08T15:30:45Z")
and date-only strings (e.g., "2023-02-08").
A string containing a date or date-time in ISO-8601/RFC-3339 format
A new CborDate instance if parsing succeeds
StaticnowCreates a new CborDate containing the current date and time.
A new CborDate instance representing the current UTC date and time
StaticwithCreates a new CborDate containing the current date and time plus the given
duration.
The duration in milliseconds to add to the current time
A new CborDate instance representing the current UTC date and time plus
the duration
Add seconds to this date.
Seconds to add (can be fractional)
New CborDate instance
Subtract seconds from this date.
Seconds to subtract (can be fractional)
New CborDate instance
Get the difference in seconds between this date and another.
Other CborDate to compare with
Difference in seconds (this - other)
Implementation of the CborTagged interface for CborDate.
This implementation specifies that CborDate values are tagged with CBOR tag 1,
which is the standard CBOR tag for date/time values represented as seconds
since the Unix epoch per RFC 8949.
A vector containing tag 1
Converts this CborDate to its untagged CBOR content: the epoch-seconds
numeric value. It may be an integer or a floating-point number,
depending on whether the date has fractional seconds.
A CBOR value representing the timestamp
The ToCbor protocol: dates encode as their tagged form.
Populates this CborDate in place from an untagged CBOR value, which
must be a number (integer or floating-point) of seconds since the Unix
epoch. The static CborDate.fromUntaggedCbor is the usual entry point;
this instance form exists for reuse.
The untagged CBOR value
this (populated in place)
StaticfromStaticfromImplementation of the toString method for CborDate.
This implementation provides a string representation of a CborDate in ISO-8601
format. For dates with time exactly at midnight (00:00:00), only the date
part is shown. For other times, a full date-time string is shown.
String representation in ISO-8601 format
// A date at midnight will display as just the date
const date = CborDate.fromYmd(2023, 2, 8);
// Returns "2023-02-08"
console.log(date.toString());
// A date with time will display as date and time
const date2 = CborDate.fromYmdHms(2023, 2, 8, 15, 30, 45);
// Returns "2023-02-08T15:30:45.000Z"
console.log(date2.toString());
Compare two dates for equality.
Other CborDate to compare
true if dates represent the same moment in time
Compare two dates.
Other CborDate to compare
-1 if this < other, 0 if equal, 1 if this > other
Convert to JSON (returns ISO 8601 string).
ISO 8601 string
Interface for types that have associated CBOR tags.
cborTags()returns tags in order of preference: the first is used when encoding; all are accepted when decoding (backward compatibility).