Boost logo

Boost :

Subject: Re: [boost] [locale] Review. Internationalization library?
From: Vicente BOTET (vicente.botet_at_[hidden])
Date: 2011-04-16 12:30:20


> Message du 16/04/11 15:22
> De : "Artyom"
> A : boost_at_[hidden]
> Copie à :
> Objet : Re: [boost] [locale] Review. Internationalization library?
>
> > > Why have you preferred to redo Boost.DateTime?
> >
> > If the DateTime library is redone, shouldn't it be released as a separated
> >one, DateTime2?
> >
>
> No, because they have very different purposes.
>
> There is almost no locale dependent libraries in Boost while
> boost::locale::date_time
> is strictly locale dependent.
>
> It provides same interface for different calendars and they may be changed in
> the runtime.

I think that internationalization is a traversal concern that could be applied to a lot of libraries. For example, it could be applied to Boost.Ratio, Boost.Chrono, Boost.Units. This doesn't means that all these libraries must be inside Boost.Locale/I18N. So yes, I'm sure that it will be better you provide a separate proposal for, let me say, Boost.Calendar or Boost.Dates that will use whatever is needed to make dates, calendars internationalizable.

> > > Do your classes preserve the same interface than Boost.DateTime?
> >
> > If not, does the documentation show the differences in a specific section?
>
> Actually almost everything there is different:
>
> http://cppcms.sourceforge.net/boost_locale/html/dates_times_timezones.html

I see this know.

> > If we follow the Chrono design, shouldn't the calendar be a template parameter
> >of the dattime class?
> >
> > What about rewriting the following
> >
> > date_time some_point = period::year * 1995 + period::january + period::day*1;
> >
> > as
> >
> > date_time some_point = year(1995) + january + day(1);
> >
> > ?
>
> Actually it may be good idea. I'm already thinking on improvement
> of date_time API due to issues rise in the review and it seems that it
> may be one of the approaches,
>
> >
> > Why your datatime class output by default as a number? Why there is no a
> >default format?
> >
>
> Because date_time is approximately a number that represents a time point
> in UTC (POSIX time) - seconds since Jan 1, 1970 GMT without leap seconds.

boost::time_point<> is also an opaque number. This doesn't mean that it is anumber. This doesn't explain why a default other than a raw number is not better. I would expect that it outputs as a date + a day time.

> But it under the hood it allows to perform date-time calculations
> according to current locale's rules.
>
> It outputs number because "it is a number of seconds since..."
> and the actual stream formatters are responsible to formatting
> it.
>
> It is covered by the links above.
>
> Basically there is a separation of roles:
>
> - date_time calculates times
> - iostream formats numbers
> - numeric representation connects between them.

I don't see an explanation to choose as default the hidden representation.

By the way, i would be interested in adapting Boost.Chrono to use Boost.Locale/I18N. Maybe a future Boost.Calendar library would use Boost.Chrono.

Best,
Vicente


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk