Commit Graph

102 Commits

Author SHA1 Message Date
Victor Zverovich
377cf203e3 Add opt out for built-in types 2024-08-29 11:21:29 -07:00
Victor Zverovich
7bd11b5cdf Remove a redundant extension to reduce divergence from std::format 2024-06-08 08:29:34 -07:00
ZaheenJ
ca8eeb09ee
Add glibc ext for day of month and week of year (#3976) 2024-05-30 10:20:56 -07:00
Victor Zverovich
c70e7b7473 Coding conventions and minor fixes 2024-04-05 08:36:45 +09:00
zivshek
71144eeaff
implement year_month_day (#3913)
* implement year_month_day, also changed weekday, day, month, year's formatter to use formatter<std::tm, Char> so they all support the format strings
* support ":L" for month and weekday
2024-04-03 15:35:53 -07:00
zivshek
74a187288b
Implemented fmt::day, fmt::month, fmt::year and related unit tests (#3906) 2024-03-27 17:10:30 -07:00
js324
34f415b56e
Fix %S formatting for chrono durations with leading zeroes (#3814) 2024-02-07 09:47:32 -08:00
Vladislav Shchapov
470c4e6ca8
Fix scope for glibc ext for sec, min, and hour (#3812)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2024-01-16 13:54:19 -08:00
Victor Zverovich
8e6b2541a6 Apply coding conventions 2023-12-30 16:07:35 -08:00
Victor Zverovich
55190dadb5 Cleanup chrono test 2023-12-29 16:34:42 -08:00
Victor Zverovich
ea1066bbe3 Cleanup test 2023-12-28 16:56:42 -08:00
Victor Zverovich
be57ec7ec0 Fix chrono-test on platforms with 32-bit time_t 2023-12-28 16:36:18 -08:00
Victor Zverovich
9048add999 Report out-of-range errors in chrono 2023-12-10 08:28:50 -08:00
Ivan Shapovalov
71bd51e6c2
Implement %j specifier for std::chrono::duration (#3732)
This adds support for `%j` presentation type for duration types:

> "If the type being formatted is a specialization of duration, the decimal
number of days without padding."

Fixes #3643.
2023-12-03 07:29:58 -08:00
Corentin Schreiber
7f8d419115
Fix overflow in time_point formatting with large dates (#3727)
* Fix #3725 and rename fmt_safe_duration_cast to fmt_duration_cast
The function is now more generic and will handle all casts. It also
takes care of toggling safe vs unsafe casts using
FMT_SAFE_DURATION_CAST.

* Refactor fmt_duration_cast to put #ifdef inside the function

* Fix compilation error with FMT_USE_LOCAL_TIME
2023-11-25 08:36:55 -08:00
Victor Zverovich
8e0ca0589f Use a more sensible locale in tests 2023-10-08 09:21:02 -07:00
Richard Kellnberger
bb8d50f04b
add a suffix for days and fix the one for minutes (#3664) 2023-10-07 12:45:34 -07:00
Victor Zverovich
e475859042 Fix overspecified tests 2023-07-20 14:09:22 -07:00
Patrick Geltinger
d7592ad8bf
Fix time_point formatting for durations with certain ratios (#3430)
* Fix time_point formatting

* Add timestamps_ratios tests
2023-05-11 15:25:21 -07:00
Vladislav Shchapov
f6276a2c2b
Force use a signed char (On ARM char is unsigned by default) (#3362)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2023-03-22 11:34:59 -07:00
Barry Revzin
93bfa05382
%T is %H:%M:%S (#3349) 2023-03-18 07:16:22 -07:00
Shawn Zhong
7718eeeacc
Implement glibc ext for sec, min, and hour (#3271) 2023-02-08 09:22:58 -08:00
Shawn Zhong
dfbb952b2c
Fix empty spec for time point (#3275) 2023-01-16 11:48:00 -08:00
Shawn Zhong
676c2a107e
Fix negative subsec for time_point (#3261) 2023-01-11 11:36:50 -08:00
Shawn Zhong
dda53082be
Support fill, align & width for time point (#3260) 2023-01-09 11:25:31 -08:00
Vladislav Shchapov
4841784e82 Simplify C99 strftime detection conditions
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-25 10:16:19 -08:00
Vladislav Shchapov
cb72c23e9e Improve timezone tests
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-25 10:16:19 -08:00
Shawn Zhong
8c56919bd2 Check chrono spec starts with % 2022-12-21 14:40:30 -08:00
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com)
115001a3b1 Formatting of system clocks ought to be to UTC, not to local time.
This improves standards conformance of fmt.
2022-12-21 14:23:02 -08:00
Vladislav Shchapov
1bf302a4ea Implement %Ez, %Oz for chrono formatter
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-12-10 10:13:53 -08:00
Stepan Ponomaryov
795ed8abf5
Add precision modifier for seconds in chrono format (#3148)
Co-authored-by: Stepan Ponomarev <stepan.ponomarev@itiviti.com>
2022-11-02 11:58:51 -07:00
Vladislav Shchapov
cd7202e039
Fix overflow error (#3143)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>

Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
2022-10-16 14:04:55 -07:00
Patrick Roocks
9254cfa6f0
Support formatting of subseconds (#3115)
* Timestamp formatting shall print also subseconds, fixed a bug for fractional durations
2022-10-12 14:33:53 -07:00
Patrick Roocks
ad719619cc
Support formatting of std time_point with utc_clock (#3110) 2022-09-28 07:31:53 -07:00
Dimitrij Mijoski
fc23cfbf4e Fix testsuite on MinGW + MSVCRT
Fixes #2952. The testsuite indirectly called strftime() with conversion
specifiers defined only in C99. In MSVCRT this function conforms only to
C89. Only in the updated UCRT this functon provides the functionality of
C99.
2022-08-14 08:40:38 -07:00
matrackif
5985f0a7d2
Fix overflow for chrono durations (#2722) 2022-01-17 12:14:59 -08:00
Victor Zverovich
d9f045fba1 Fix a UB in chrono 2022-01-09 14:06:13 -08:00
matrackif
0bbc9708f9
Implement c++20 std::chrono::duration subsecond formatting (#2623)
* Add support for subsecond printing for std::chrono::duration according to the c++20 standard

* Remove assert test that overflows intmax_t

* * Hopefully fix int64_t to int32_t conversion errors.
* Allow proper Duration::rep type to propagate via template argument deduction

* * Hopefully fix int64_t to int32_t conversion errors.
* Allow proper Duration::rep type to propagate via template argument deduction

* Fix sign conversion (-Wsign-conversion) warning treated as error in num_digits()

* Format chrono.h with clang-format

* Remove extra forward slash in doxygen style comment

Co-authored-by: Victor Zverovich <victor.zverovich@gmail.com>

* Apply all suggestions from GitHub, except for replacing the utility subsecond_helper class with a function

* * Move logic of handling subseconds from utility class to function with name write_fractional_seconds()
* Revert write(Rep value, int width) function to previous state

* Fix -Wshadow warning

* Remove unsued get_subseconds() function, its logic has been moved to write_fractional_seconds()

* Change comment from lowercase int to uppercase Int

* Simplify test check

* Integrate suggested changes

* Remove static from detail functions, they are no longer member functions of a class and static is unnecessary.
* Change comment from "amount" to "number"

Co-authored-by: Victor Zverovich <victor.zverovich@gmail.com>
2021-12-09 06:45:13 -08:00
Florin Iucha
acad8cfab1 Reformat all source code; no functional changes
Before adding the format checker, the mainline should be clean, to
avoid false failures.
2021-11-25 09:15:25 -08:00
Florin Iucha
491ba2dda5 Annotate fmt::format and fmt::formatted_size as [[nodiscard]]
This prevents accidentally writing fmt::format when fmt::print was
intended. Other than running tests, there's not a good use case for
discarding the formatted output.
2021-11-25 07:30:30 -08:00
Vladislav Shchapov
5abe9e8266 Add platform-specific 'z' formatter 2021-11-25 06:52:39 -08:00
lukester1975
12b1d8b14a
Fix precision 0 with std::chrono::duration and added additional tests. (#2588) 2021-11-06 08:57:22 -07:00
Victor Zverovich
5b0aa638cf Minor grammar fix 2021-10-30 09:14:13 -07:00
Vladislav Shchapov
1031eedf27
Replacing strftime with std::time_put (#2550)
* Fix unicode test

* Add xchar support to chrono formatter

* Replace strftime with std::time_put

* Add std::locale support to std::tm formatter

* Use predefined names and formats for C-locale

* Performance improvement

* Make locale-independent and C locale formats consistent among platforms
2021-10-30 08:25:45 -07:00
Vladislav Shchapov
90034e4c4b
Add FMT_ASSERT and validation of values of struct tm members (#2564)
Switch internal year calculations to long long
2021-10-27 13:29:07 -07:00
Vladislav Shchapov
aeb54b0dd9 Fix bug on '%Y' and '%C' formats with negative years
Requested changes
2021-10-16 15:03:57 -07:00
Vladislav Shchapov
f88c020fc0 Generalization of strftime/wcsftime function calls in tests 2021-10-16 15:03:57 -07:00
Vladislav Shchapov
2754546080 Fix errors in ISO week-base-year formatter 2021-10-16 15:03:57 -07:00
Vladislav Shchapov
218cecb6d1 Fix error in test 2021-10-16 15:03:57 -07:00
Vladislav Shchapov
5dc3dd3d4a New tests 2021-10-16 15:03:57 -07:00