formatting broken in czech (and others?)

Open
#83 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
cpp

Research direction

Start with the provided test_datetime.c reproducer and the boost::posix_time::time_facet construction using nl_langinfo(D_FMT). Run it with LANG=cs_CZ.UTF-8, then investigate how the facet handles the '-' modifier and the O/E modifiers. Done means locale formats no longer emit unsupported modifiers and the reported Czech output is corrected.

Written by the indexing model from the issue text.

Description

enhancement

Using boost 1.66.0 (Fedora 28, if that matters)

#include <langinfo.h>
#include <iostream>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/local_time/local_time.hpp>
#include <boost/regex.hpp>


int main(int argc, char **argv) {
    namespace pt = boost::posix_time;
    pt::ptime now = pt::second_clock::local_time();
    using Facet = boost::posix_time::time_facet;
    std::stringstream ss;
    char *fmt;

    setlocale(LC_ALL, "");
    fmt = nl_langinfo(D_FMT);

    auto output_facet(new Facet(fmt));
    ss.imbue(std::locale(std::locale(), output_facet));
    ss << now;
    std::cout << ss.str() << std::endl;
}

Compile and run.

[notting@nostromo: ~]$ g++ -Wall -o test_datetime test_datetime.c  -lboost_date_time
[notting@nostromo: ~]$ LANG=cs_CZ.UTF-8 ./test_datetime 
%-d.%-m.2018

boost is not working properly in the presence of the - modifier. It also appears to ignore the O and E modifiers (used in Persian and other languages), but those at least still substitute ascii numbers properly.

Dominant language
C++
Stars
70
Forks
99
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from boostorg/date_time

All issues in boostorg/date_time

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.