HowardHinnant / date

A date and time library based on the C++11/14/17 <chrono> header
Other
3.08k stars 669 forks source link

[Question] Why are there two adjacent space characters (`0x20`) in the `what()` message of `ambiguous_local_time`? #782

Closed JMazurkiewicz closed 1 year ago

JMazurkiewicz commented 1 year ago

Repro:

#include <chrono>
#include <date/tz.h>
#include <iostream>

int main() {
  using namespace date;
  using namespace std::chrono_literals;
  try {
    auto zt = zoned_time{"America/New_York",
                         local_days{Sunday[1] / November / 2016} + 1h + 30min};
  } catch (const ambiguous_local_time &e) {
    std::cout << e.what() << '\n';
  }
}

Result:

$ g++ main.cpp -std=c++20 -I../include ../build/libdate-tz.a
$ ./a.out
2016-11-06 01:30:00 is ambiguous.  It could be
2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or
2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTC

Why are there two space characters between "ambiguous." and "It could"? Is there any reason or is it just a typo?

If it is a typo:

HowardHinnant commented 1 year ago

Blame it on my 2nd grade teacher ... and this: https://www.gocomics.com/bloom-county/2015/10/04

jleffler commented 1 year ago

Traditionally, two spaces were placed after the end of one sentence and before the beginning of the next in type-written text. So, it could be just a carry-over of that convention.

On Wed, Apr 12, 2023 at 2:35 AM Jakub Mazurkiewicz @.***> wrote:

Repro:

include

include <date/tz.h>

include

int main() { using namespace date; using namespace std::chrono_literals; try { auto zt = zoned_time{"America/New_York", local_days{Sunday[1] / November / 2016} + 1h + 30min}; } catch (const ambiguous_local_time &e) { std::cout << e.what() << '\n'; } }

Result:

$ g++ main.cpp -std=c++20 -I../include ../build/libdate-tz.a $ ./a.out2016-11-06 01:30:00 is ambiguous. It could be2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTC

Why are there two space characters between "ambiguous." and "It could"? Is there any reason or is it just a typo?

If it is a typo:

— Reply to this email directly, view it on GitHub https://github.com/HowardHinnant/date/issues/782, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACCAHBQRTTS77CL77XDAQEDXAZSLPANCNFSM6AAAAAAW3LHCTM . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Jonathan Leffler @.***> #include Guardian of DBD::Informix - v2018.1031 - http://dbi.perl.org "Blessed are we who can laugh at ourselves, for we shall never cease to be amused."

JMazurkiewicz commented 1 year ago

Thanks for explanation, to be honest I've never seen two spaces separating sentences (only one).