10
10
#ifndef _LIBCPP___CHRONO_FORMATTER_H
11
11
#define _LIBCPP___CHRONO_FORMATTER_H
12
12
13
- #include < __algorithm/ranges_copy.h>
14
- #include < __chrono/calendar.h>
15
- #include < __chrono/concepts.h>
16
- #include < __chrono/convert_to_tm.h>
17
- #include < __chrono/day.h>
18
- #include < __chrono/duration.h>
19
- #include < __chrono/file_clock.h>
20
- #include < __chrono/hh_mm_ss.h>
21
- #include < __chrono/local_info.h>
22
- #include < __chrono/month.h>
23
- #include < __chrono/month_weekday.h>
24
- #include < __chrono/monthday.h>
25
- #include < __chrono/ostream.h>
26
- #include < __chrono/parser_std_format_spec.h>
27
- #include < __chrono/statically_widen.h>
28
- #include < __chrono/sys_info.h>
29
- #include < __chrono/system_clock.h>
30
- #include < __chrono/time_point.h>
31
- #include < __chrono/weekday.h>
32
- #include < __chrono/year.h>
33
- #include < __chrono/year_month.h>
34
- #include < __chrono/year_month_day.h>
35
- #include < __chrono/year_month_weekday.h>
36
- #include < __chrono/zoned_time.h>
37
- #include < __concepts/arithmetic.h>
38
- #include < __concepts/same_as.h>
39
13
#include < __config>
40
- #include < __format/concepts.h>
41
- #include < __format/format_error.h>
42
- #include < __format/format_functions.h>
43
- #include < __format/format_parse_context.h>
44
- #include < __format/formatter.h>
45
- #include < __format/parser_std_format_spec.h>
46
- #include < __format/write_escaped.h>
47
- #include < __memory/addressof.h>
48
- #include < __type_traits/is_specialization.h>
49
- #include < cmath>
50
- #include < ctime>
51
- #include < limits>
52
- #include < sstream>
53
- #include < string_view>
54
-
55
- #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
56
- # pragma GCC system_header
57
- #endif
14
+
15
+ #ifndef _LIBCPP_HAS_NO_LOCALIZATION
16
+
17
+ # include < __algorithm/ranges_copy.h>
18
+ # include < __chrono/calendar.h>
19
+ # include < __chrono/concepts.h>
20
+ # include < __chrono/convert_to_tm.h>
21
+ # include < __chrono/day.h>
22
+ # include < __chrono/duration.h>
23
+ # include < __chrono/file_clock.h>
24
+ # include < __chrono/hh_mm_ss.h>
25
+ # include < __chrono/local_info.h>
26
+ # include < __chrono/month.h>
27
+ # include < __chrono/month_weekday.h>
28
+ # include < __chrono/monthday.h>
29
+ # include < __chrono/ostream.h>
30
+ # include < __chrono/parser_std_format_spec.h>
31
+ # include < __chrono/statically_widen.h>
32
+ # include < __chrono/sys_info.h>
33
+ # include < __chrono/system_clock.h>
34
+ # include < __chrono/time_point.h>
35
+ # include < __chrono/weekday.h>
36
+ # include < __chrono/year.h>
37
+ # include < __chrono/year_month.h>
38
+ # include < __chrono/year_month_day.h>
39
+ # include < __chrono/year_month_weekday.h>
40
+ # include < __chrono/zoned_time.h>
41
+ # include < __concepts/arithmetic.h>
42
+ # include < __concepts/same_as.h>
43
+ # include < __format/concepts.h>
44
+ # include < __format/format_error.h>
45
+ # include < __format/format_functions.h>
46
+ # include < __format/format_parse_context.h>
47
+ # include < __format/formatter.h>
48
+ # include < __format/parser_std_format_spec.h>
49
+ # include < __format/write_escaped.h>
50
+ # include < __memory/addressof.h>
51
+ # include < __type_traits/is_specialization.h>
52
+ # include < cmath>
53
+ # include < ctime>
54
+ # include < limits>
55
+ # include < sstream>
56
+ # include < string_view>
57
+
58
+ # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
59
+ # pragma GCC system_header
60
+ # endif
58
61
59
62
_LIBCPP_BEGIN_NAMESPACE_STD
60
63
61
- #if _LIBCPP_STD_VER >= 20
64
+ # if _LIBCPP_STD_VER >= 20
62
65
63
66
namespace __formatter {
64
67
@@ -139,24 +142,24 @@ __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<
139
142
__value.fractional_width );
140
143
}
141
144
142
- # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
143
- !defined(_LIBCPP_HAS_NO_FILESYSTEM) && !defined(_LIBCPP_HAS_NO_LOCALIZATION )
145
+ # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
146
+ !defined(_LIBCPP_HAS_NO_FILESYSTEM )
144
147
template <class _CharT , class _Duration , class _TimeZonePtr >
145
148
_LIBCPP_HIDE_FROM_ABI void
146
149
__format_sub_seconds (basic_stringstream<_CharT>& __sstr, const chrono::zoned_time<_Duration, _TimeZonePtr>& __value) {
147
150
__formatter::__format_sub_seconds (__sstr, __value.get_local_time ().time_since_epoch ());
148
151
}
149
- # endif
152
+ # endif
150
153
151
154
template <class _Tp >
152
155
consteval bool __use_fraction () {
153
156
if constexpr (__is_time_point<_Tp>)
154
157
return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
155
- # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
156
- ! defined (_LIBCPP_HAS_NO_FILESYSTEM) && !defined (_LIBCPP_HAS_NO_LOCALIZATION )
158
+ # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB) && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && \
159
+ !defined (_LIBCPP_HAS_NO_FILESYSTEM )
157
160
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
158
161
return chrono::hh_mm_ss<typename _Tp::duration>::fractional_width;
159
- # endif
162
+ # endif
160
163
else if constexpr (chrono::__is_duration<_Tp>::value)
161
164
return chrono::hh_mm_ss<_Tp>::fractional_width;
162
165
else if constexpr (__is_hh_mm_ss<_Tp>)
@@ -225,16 +228,15 @@ struct _LIBCPP_HIDE_FROM_ABI __time_zone {
225
228
226
229
template <class _Tp >
227
230
_LIBCPP_HIDE_FROM_ABI __time_zone __convert_to_time_zone ([[maybe_unused]] const _Tp& __value) {
228
- # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
231
+ # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
229
232
if constexpr (same_as<_Tp, chrono::sys_info>)
230
233
return {__value.abbrev , __value.offset };
231
- # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
232
- !defined (_LIBCPP_HAS_NO_LOCALIZATION)
234
+ # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
233
235
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
234
236
return __formatter::__convert_to_time_zone (__value.get_info ());
235
- # endif
237
+ # endif
236
238
else
237
- # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
239
+ # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
238
240
return {" UTC" , chrono::seconds{0 }};
239
241
}
240
242
@@ -341,12 +343,12 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
341
343
//
342
344
// TODO FMT evaluate the comment above.
343
345
344
- # if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
346
+ # if defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
345
347
case _CharT (' y' ):
346
348
// Glibc fails for negative values, AIX for positive values too.
347
349
__sstr << std::format (_LIBCPP_STATICALLY_WIDEN (_CharT, " {:02}" ), (std::abs (__t .tm_year + 1900 )) % 100 );
348
350
break ;
349
- # endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
351
+ # endif // defined(__GLIBC__) || defined(_AIX) || defined(_WIN32)
350
352
351
353
case _CharT (' Y' ):
352
354
// Depending on the platform's libc the range of supported years is
@@ -442,17 +444,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_ok(const _Tp& __value) {
442
444
return __value.weekday ().ok ();
443
445
else if constexpr (__is_hh_mm_ss<_Tp>)
444
446
return true ;
445
- # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
447
+ # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
446
448
else if constexpr (same_as<_Tp, chrono::sys_info>)
447
449
return true ;
448
450
else if constexpr (same_as<_Tp, chrono::local_info>)
449
451
return true ;
450
- # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
451
- !defined (_LIBCPP_HAS_NO_LOCALIZATION)
452
+ # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
452
453
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
453
454
return true ;
454
- # endif
455
- # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
455
+ # endif
456
+ # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
456
457
else
457
458
static_assert (sizeof (_Tp) == 0 , " Add the missing type specialization" );
458
459
}
@@ -493,17 +494,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __weekday_name_ok(const _Tp& __value) {
493
494
return __value.weekday ().ok ();
494
495
else if constexpr (__is_hh_mm_ss<_Tp>)
495
496
return true ;
496
- # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
497
+ # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
497
498
else if constexpr (same_as<_Tp, chrono::sys_info>)
498
499
return true ;
499
500
else if constexpr (same_as<_Tp, chrono::local_info>)
500
501
return true ;
501
- # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
502
- !defined (_LIBCPP_HAS_NO_LOCALIZATION)
502
+ # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
503
503
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
504
504
return true ;
505
- # endif
506
- # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
505
+ # endif
506
+ # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
507
507
else
508
508
static_assert (sizeof (_Tp) == 0 , " Add the missing type specialization" );
509
509
}
@@ -544,17 +544,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __date_ok(const _Tp& __value) {
544
544
return __value.ok ();
545
545
else if constexpr (__is_hh_mm_ss<_Tp>)
546
546
return true ;
547
- # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
547
+ # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
548
548
else if constexpr (same_as<_Tp, chrono::sys_info>)
549
549
return true ;
550
550
else if constexpr (same_as<_Tp, chrono::local_info>)
551
551
return true ;
552
- # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
553
- !defined (_LIBCPP_HAS_NO_LOCALIZATION)
552
+ # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
554
553
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
555
554
return true ;
556
- # endif
557
- # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
555
+ # endif
556
+ # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
558
557
else
559
558
static_assert (sizeof (_Tp) == 0 , " Add the missing type specialization" );
560
559
}
@@ -595,17 +594,16 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool __month_name_ok(const _Tp& __value) {
595
594
return __value.month ().ok ();
596
595
else if constexpr (__is_hh_mm_ss<_Tp>)
597
596
return true ;
598
- # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
597
+ # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
599
598
else if constexpr (same_as<_Tp, chrono::sys_info>)
600
599
return true ;
601
600
else if constexpr (same_as<_Tp, chrono::local_info>)
602
601
return true ;
603
- # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
604
- !defined (_LIBCPP_HAS_NO_LOCALIZATION)
602
+ # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
605
603
else if constexpr (__is_specialization_v<_Tp, chrono::zoned_time>)
606
604
return true ;
607
- # endif
608
- # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
605
+ # endif
606
+ # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
609
607
else
610
608
static_assert (sizeof (_Tp) == 0 , " Add the missing type specialization" );
611
609
}
@@ -943,7 +941,7 @@ struct formatter<chrono::hh_mm_ss<_Duration>, _CharT> : public __formatter_chron
943
941
}
944
942
};
945
943
946
- # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
944
+ # if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
947
945
template <__fmt_char_type _CharT>
948
946
struct formatter <chrono::sys_info, _CharT> : public __formatter_chrono<_CharT> {
949
947
public:
@@ -965,8 +963,7 @@ struct formatter<chrono::local_info, _CharT> : public __formatter_chrono<_CharT>
965
963
return _Base::__parse (__ctx, __format_spec::__fields_chrono, __format_spec::__flags{});
966
964
}
967
965
};
968
- # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \
969
- !defined(_LIBCPP_HAS_NO_LOCALIZATION)
966
+ # if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
970
967
// Note due to how libc++'s formatters are implemented there is no need to add
971
968
// the exposition only local-time-format-t abstraction.
972
969
template <class _Duration , class _TimeZonePtr , __fmt_char_type _CharT>
@@ -979,12 +976,13 @@ struct formatter<chrono::zoned_time<_Duration, _TimeZonePtr>, _CharT> : public _
979
976
return _Base::__parse (__ctx, __format_spec::__fields_chrono, __format_spec::__flags::__clock);
980
977
}
981
978
};
982
- # endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) &&
983
- // !defined(_LIBCPP_HAS_NO_LOCALIZATION)
984
- # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
979
+ # endif // !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM)
980
+ # endif // !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
985
981
986
- #endif // if _LIBCPP_STD_VER >= 20
982
+ # endif // if _LIBCPP_STD_VER >= 20
987
983
988
984
_LIBCPP_END_NAMESPACE_STD
989
985
986
+ #endif // !_LIBCPP_HAS_NO_LOCALIZATION
987
+
990
988
#endif // _LIBCPP___CHRONO_FORMATTER_H
0 commit comments