|
65 | 65 | * │ 2024-01-15T12:30:45Z │ Jan 15, 2024, 12:30:45 UTC │ |
66 | 66 | * │ 2024-06-20T00:00:00Z │ Jun 20, 2024, midnight UTC │ |
67 | 67 | * │ 2024-12-31T23:59:59Z │ Dec 31, 2024, 23:59:59 UTC │ |
68 | | - * │ 2024-01-15T12:30:45.123Z │ With milliseconds (123 ms) │ |
69 | | - * │ 2024-01-15T12:30:45.123456Z │ With microseconds (123.456 ms) │ |
| 68 | + * │ 2024-01-15T12:30:45.1230000Z │ With 7-digit fractions (123 ms) │ |
| 69 | + * │ 2024-01-15T12:30:45.1234560Z │ With microseconds (123.456 ms) │ |
70 | 70 | * │ 2024-01-15T12:30:45.1234567Z │ Full precision (100 ns ticks) │ |
71 | 71 | * │ 1970-01-01T00:00:00Z │ Unix epoch (start of Unix time) │ |
72 | 72 | * │ 0001-01-01T00:00:00Z │ Minimum DateTime value │ |
|
178 | 178 | * │ DateTime fromEpoch{ DateTime::fromEpochSeconds(epochSecs) }; │ |
179 | 179 | * │ │ |
180 | 180 | * │ // Format output │ |
181 | | - * │ std::string basic{ dt.toString() }; // Basic ISO 8601 │ |
182 | | - * │ std::string precise{ dt.toIso8601Extended() }; // With fractions │ |
| 181 | + * │ std::string iso{ dt.toString(Format::Iso8601) }; │ |
| 182 | + * │ std::string precise{ dt.toString(Format::Iso8601Precise) }; │ |
183 | 183 | * └──────────────────────────────────────────────────────────────────────┘ |
184 | 184 | * @endcode |
185 | 185 | * |
@@ -233,25 +233,28 @@ namespace nfx::time |
233 | 233 | */ |
234 | 234 | enum class Format : std::uint8_t |
235 | 235 | { |
236 | | - /** @brief ISO 8601 basic format: "2024-01-01T12:00:00Z" */ |
237 | | - Iso8601Basic, |
| 236 | + /** @brief ISO 8601 with seconds precision: "2024-01-01T12:00:00Z" */ |
| 237 | + Iso8601, |
238 | 238 |
|
239 | | - /** @brief ISO 8601 extended format with fractional seconds: "2024-01-01T12:00:00.1234567Z" */ |
240 | | - Iso8601Extended, |
| 239 | + /** @brief ISO 8601 with full tick precision (7 decimal digits): "2024-01-01T12:00:00.1234567Z" */ |
| 240 | + Iso8601Precise, |
241 | 241 |
|
242 | | - /** @brief Date and time with timezone: "2024-01-01T12:00:00+02:00" */ |
| 242 | + /** @brief ISO 8601 with numeric offset (always +00:00 for DateTime): "2024-01-01T12:00:00+00:00" */ |
243 | 243 | Iso8601WithOffset, |
244 | 244 |
|
245 | | - /** @brief Date only format: "2024-01-01" */ |
246 | | - DateOnly, |
| 245 | + /** @brief ISO 8601 compact form without separators: "20240101T120000Z" */ |
| 246 | + Iso8601Compact, |
247 | 247 |
|
248 | | - /** @brief Time only: "12:00:00" */ |
249 | | - TimeOnly, |
| 248 | + /** @brief ISO 8601 date only: "2024-01-01" */ |
| 249 | + Iso8601Date, |
250 | 250 |
|
251 | | - /** @brief Epoch timestamp format: "1704110400" (seconds since epoch) */ |
| 251 | + /** @brief ISO 8601 time only: "12:00:00" */ |
| 252 | + Iso8601Time, |
| 253 | + |
| 254 | + /** @brief Unix epoch seconds (integer): "1704110400" */ |
252 | 255 | UnixSeconds, |
253 | 256 |
|
254 | | - /** @brief Epoch timestamp with milliseconds: "1704110400123" */ |
| 257 | + /** @brief Unix epoch milliseconds (integer): "1704110400000" */ |
255 | 258 | UnixMilliseconds, |
256 | 259 | }; |
257 | 260 |
|
@@ -632,27 +635,13 @@ namespace nfx::time |
632 | 635 | // String formatting |
633 | 636 | //---------------------------------------------- |
634 | 637 |
|
635 | | - /** |
636 | | - * @brief Convert to ISO 8601 string (basic format) |
637 | | - * @return String representation in ISO 8601 basic format (e.g., "2024-01-01T12:00:00Z") |
638 | | - * @note This function is marked [[nodiscard]] - the return value should not be ignored |
639 | | - */ |
640 | | - [[nodiscard]] std::string toString() const; |
641 | | - |
642 | 638 | /** |
643 | 639 | * @brief Convert to string using specified format |
644 | 640 | * @param format The format to use for string conversion |
645 | 641 | * @return String representation using the specified format |
646 | 642 | * @note This function is marked [[nodiscard]] - the return value should not be ignored |
647 | 643 | */ |
648 | | - [[nodiscard]] std::string toString( Format format ) const; |
649 | | - |
650 | | - /** |
651 | | - * @brief Convert to ISO 8601 extended format with full precision |
652 | | - * @return String representation in ISO 8601 extended format with fractional seconds (e.g., "2024-01-01T12:00:00.1234567Z") |
653 | | - * @note This function is marked [[nodiscard]] - the return value should not be ignored |
654 | | - */ |
655 | | - [[nodiscard]] std::string toIso8601Extended() const; |
| 644 | + [[nodiscard]] std::string toString( Format format = Format::Iso8601 ) const; |
656 | 645 |
|
657 | 646 | //---------------------------------------------- |
658 | 647 | // std::chrono interoperability |
|
0 commit comments