Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions stl/inc/chrono
Original file line number Diff line number Diff line change
Expand Up @@ -5966,8 +5966,10 @@ namespace chrono {
}
}

return _Write_aligned(_STD move(_FormatCtx.out()), static_cast<int>(_Stream.view().size()), _Specs,
_Fmt_align::_Left, [&](auto _Out) { return _Fmt_write(_STD move(_Out), _Stream.view()); });
int _Estimated_width = -1;
(void) _Measure_string_prefix(_Stream.view(), _Estimated_width);
return _Write_aligned(_STD move(_FormatCtx.out()), _Estimated_width, _Specs, _Fmt_align::_Left,
[&](auto _Out) { return _Fmt_write(_STD move(_Out), _Stream.view()); });
}

// This echoes the functionality of put_time, but is able to handle invalid dates (when !ok()) since the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\concepts_latest_matrix.lst
RUNALL_CROSSLIST
PM_CL="/utf-8"
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

#include <assert.h>
#include <chrono>
#include <clocale>
#include <concepts>
#include <format>
#include <iostream>
#include <locale>
#include <sstream>
#include <stdio.h>
#include <string>
Expand All @@ -29,6 +31,13 @@ template <typename CharT>

#define STR(Literal) (choose_literal<CharT>(Literal, L##Literal))

// Test against IDL mismatch between the DLL which stores the locale and the code which uses it.
#ifdef _DEBUG
#define DEFAULT_IDL_SETTING 2
#else
#define DEFAULT_IDL_SETTING 0
#endif

template <typename CharT>
struct testing_callbacks {
_Fmt_align expected_alignment = _Fmt_align::_None;
Expand Down Expand Up @@ -884,6 +893,12 @@ void test_zoned_time_formatter() {
assert(format(STR("{:%g %G %U %V %W}"), zt) == STR("21 2021 16 16 16"));
}

template <typename CharT>
void test_locale() {
assert(format(locale{"zh-CN"}, STR("{:^22%Y %B %d %A}"), 2021y / June / 16d)
== STR(" 2021 \u516D\u6708 16 \u661F\u671F\u4E09 "));
}

void test() {
test_parse_conversion_spec<char>();
test_parse_conversion_spec<wchar_t>();
Expand Down Expand Up @@ -955,6 +970,14 @@ void test() {

test_zoned_time_formatter<char>();
test_zoned_time_formatter<wchar_t>();

#if !defined(_DLL) || _ITERATOR_DEBUG_LEVEL == DEFAULT_IDL_SETTING
test_locale<wchar_t>();
#ifndef MSVC_INTERNAL_TESTING // TRANSITION, the Windows version on Contest VMs doesn't always understand ".UTF-8"
assert(setlocale(LC_ALL, ".UTF-8") != nullptr);
test_locale<char>();
#endif // MSVC_INTERNAL_TESTING
#endif // !defined(_DLL) || _ITERATOR_DEBUG_LEVEL == DEFAULT_IDL_SETTING
}

int main() {
Expand Down