date icon indicating copy to clipboard operation
date copied to clipboard

Quick question about casting day, month and year

Open QuantDevHacks opened this issue 2 years ago • 1 comments

Quick question:

Might you tell me the reasoning behind day and month types being cast to unsigned, while year types are cast to int?

Thanks in advance.

QuantDevHacks avatar Nov 08 '22 06:11 QuantDevHacks

The rationale was simply to enforce that negative integral values for month are never represented (ditto for day), while they are for year. It was realized that this design choice had a small cost in terms of homogeneity. And that was weighed against the small benefit of enforcing lack of negative values for month and day. I recognized this as a small-cost / small-benefit design decision and landed with where it is today.

HowardHinnant avatar Nov 08 '22 13:11 HowardHinnant