Updated FAQ (markdown)

mcguip
2018-01-08 12:04:41 +00:00
parent f960d12e2e
commit e0095170d4

11
FAQ.md

@@ -2,7 +2,7 @@
- [Why can't I do day arithmetic on a `year_month_day`?](#day_arithmetic)
- [Why is `%A` failing?](#week_day_parse_bug)
- [Why is `local_t` not a proper clock?](#local_t)
- [Why can't I compare instances of `zoned_time`?](#zoned_time_comparison)
***
<a name="day_arithmetic"></a>
@@ -120,4 +120,11 @@ The proper way to do this is to pair `tp` with some timezone creating a `zoned_t
std::this_thread::sleep_until(zt.get_sys_time());
This compiles and will do exactly what it looks like it does: Sleeps until Nov. 6, 2016 07:00:00 in New York. This works correctly even if there is a daylight saving transition between the time the `sleep_until` is called, and the time to wake up (currently such a transition is scheduled 6 hours earlier than the wakeup time). It works because all `sleep_until` has to worry about is the `sys_time` (`time_point<system_clock, Duration>`) it was handed, and that `sys_time` has been correctly mapped from "America/New_York".
This compiles and will do exactly what it looks like it does: Sleeps until Nov. 6, 2016 07:00:00 in New York. This works correctly even if there is a daylight saving transition between the time the `sleep_until` is called, and the time to wake up (currently such a transition is scheduled 6 hours earlier than the wakeup time). It works because all `sleep_until` has to worry about is the `sys_time` (`time_point<system_clock, Duration>`) it was handed, and that `sys_time` has been correctly mapped from "America/New_York".
<a name="zoned_time_comparison"></a>
### Why can't I compare instances of `zoned_time`?
When working with `zoned_time` objects, it seems natural that one should be able to make comparisons between two instances in relation to the instant in time each represents. Though each `zoned_time` references a `sys_time`, it also has an associated local timezone complicates the consideration of how operators like `<` should be defined. Such operations could be defined relative to `sys_time` or to `sys_time` and `time_zone*`, though there are issues with each. For two instances of `zoned_time` `x` and `y`, `operator<` could be defined as `x.get_sys_time() < y.get_sys_time()`; however, there would then be cases where `!(x < y) && !(y < x) && x != y`, which breaks not only with tradition but probably several algorithms as well. I.e. if `x` and `y` have the same `sys_time`, but different `time_zone*`.
In the case that comparison is required by an application, named functors or lambdas defining the comparison operations should be used.