Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add locale getter in tm_writer #3147

Merged
merged 2 commits into from
Oct 20, 2022

Conversation

SappyJoy
Copy link
Contributor

Why not?

Example of usage in custom DateTime writer:

template <typename OutputIt, typename Char>
class DateTimeWriter : public fmt::detail::tm_writer<OutputIt, Char>
{
    using super = fmt::detail::tm_writer<OutputIt, Char>;

public:
    DateTimeWriter(const std::locale & loc,
                   OutputIt out,
                   const std::tm & tm,
                   const int32_t usec,
                   const char * zone)
        : super(loc, out, tm)
        , m_usec(usec)
        , m_zone(zone)
    {
    }

    void on_tz_name()
    {
        super::out() = detail::write_tm_str<Char>(
                super::out(), m_zone, super::locale());    // <----- tm_writer::locale()
    }

@@ -1263,6 +1263,8 @@ class tm_writer {

OutputIt out() const { return out_; }

const std::locale & locale() const { return loc_; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apply clang-format.

@vitaut vitaut merged commit 64965bd into fmtlib:master Oct 20, 2022
@vitaut
Copy link
Contributor

vitaut commented Oct 20, 2022

Merged, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants