Repository: microsoft/terminal
File: src/cascadia/TerminalApp/TerminalPage.cpp (C++)

Code before:
    // - <none>
    void TerminalPage::_OnInputSuggestionRequested(const IInspectable& /*sender*/, const winrt::hstring& suggestion)
    {
        if (auto activeControl = _GetActiveControl())
        {
            activeControl.SendInput(suggestion);
        }
    }

    // Method Description:
    // - This method is called when the user clicks the "export message history" button
    //   in the query palette
    // Arguments:
    // - text - the text to export
    // Return Value:
    // - <none>
    void TerminalPage::_OnExportChatHistoryRequested(const IInspectable& /*sender*/, const winrt::hstring& text)
    {
        auto now = std::chrono::system_clock::now();
        auto time = std::chrono::system_clock::to_time_t(now);

        std::tm local_time;
        localtime_s(&local_time, &time);

        std::stringstream ss;
        ss << std::put_time(&local_time, "%m%d%Y-%H%M");
        std::string time_str = ss.str();
        const auto defaultFileName = RS_(L"TerminalChatHistoryDefaultFileName") + winrt::to_hstring(time_str);

        _SaveFileHelper(text, L"", defaultFileName);
    }

    fire_and_forget TerminalPage::_SaveFileHelper(const winrt::hstring& text, const winrt::hstring& filepath, const std::wstring_view filename)
    {
        // This will be used to set up the file picker "filter", to select .txt
        // files by default.
        static constexpr COMDLG_FILTERSPEC supportedFileTypes[] = {
            { L"Text Files (*.txt)", L"*.txt" },
            { L"All Files (*.*)", L"*.*" }
        };
        // An arbitrary GUID to associate with all instances of this
        // dialog, so they all re-open in the same path as they were
        // open before:
        static constexpr winrt::guid clientGuidExportFile{ 0xF6AF20BB, 0x0800, 0x48E6, { 0xB0, 0x17, 0xA1, 0x4C, 0xD8, 0x73, 0xDD, 0x58 } };

        try
        {
            auto path = filepath;

            if (path.empty())
            {

Review comment (bug):
There are only a hand full of countries in the world which use the MM DD YYYY date format. Something like this would respect the users settings:
```cpp
SYSTEMTIME time;
GetLocalTime(&time);

wchar_t dateBuf[256];
wchar_t timeBuf[256];
const auto dateLen = GetDateFormatEx(nullptr, 0, &time, nullptr, &dateBuf[0], ARRAYSIZE(dateBuf), nullptr);
const auto timeLen = GetTimeFormatEx(nullptr, 0, &time, nullptr, &timeBuf[0], ARRAYSIZE(timeBuf));

const std::wstring_view date{ &dateBuf[0], gsl::narrow_cast<size_t>(dateLen) };
const std::wstring_view time{ &timeBuf[0], gsl::narrow_cast<size_t>(timeLen) };

fmt::format(FMT_COMPILE(L"{} {}"), date, time);
```

However, I think RFC 3339 would be just as good if not better. Something like this:
```cpp
time_t nowTime;
time(&nowTime);

tm nowTm;
gmtime_s(&nowTm, &nowTime);

wchar_t buf[64];
size_t len = wcsftime(&buf[0], ARRAYSIZE(buf), L"%F %T", &nowTm);
```

Code after:
    // - suggestion - suggestion to dispatch
    // Return Value:
    // - <none>
    void TerminalPage::_OnInputSuggestionRequested(const IInspectable& /*sender*/, const winrt::hstring& suggestion)
    {
        if (auto activeControl = _GetActiveControl())
        {
            activeControl.SendInput(suggestion);
        }
    }

    // Method Description:
    // - This method is called when the user clicks the "export message history" button
    //   in the query palette
    // Arguments:
    // - text - the text to export
    // Return Value:
    // - <none>
    void TerminalPage::_OnExportChatHistoryRequested(const IInspectable& /*sender*/, const winrt::hstring& text)
    {
        time_t nowTime;
        time(&nowTime);

        tm nowTm;
        localtime_s(&nowTm, &nowTime);

        wchar_t buf[64];
        wcsftime(&buf[0], ARRAYSIZE(buf), L"%F %T", &nowTm);

        const auto defaultFileName = RS_(L"TerminalChatHistoryDefaultFileName") + winrt::to_hstring(buf);

        // An arbitrary GUID to associate with all instances of the save file dialog
        // for exporting terminal chat histories, so they all re-open in the same path as they were
        // open before:
        static constexpr winrt::guid terminalChatSaveFileDialogGuid{ 0xc3e449f6, 0x1b5, 0x44e0, { 0x9e, 0x6d, 0x63, 0xca, 0x15, 0x43, 0x4b, 0xdc } };

        _SaveStringToFileOrPromptUser(text, L"", defaultFileName, terminalChatSaveFileDialogGuid);
    }

    // Method Description:
    // - Saves the given text to the file path provided, or prompts the user for the location to save it
    // Arguments:
    // - text - the text to save
    // - filepath - the location to save the text
    // - filename - the name of the file to save the text to
    // - dialogGuid - the guid to associate with these specific saves (determines where the save dialog opens to by default)
    fire_and_forget TerminalPage::_SaveStringToFileOrPromptUser(const winrt::hstring& text, const winrt::hstring& filepath, const std::wstring_view filename, const winrt::guid dialogGuid)
    {
        // This will be used to set up the file picker "filter", to select .txt
        // files by default.
        static constexpr COMDLG_FILTERSPEC supportedFileTypes[] = {