@@ -177,14 +177,11 @@ std::optional<local_time_point> local_time_point_from_string(std::string_view st
177177#ifdef HAVE_CPP20_CHRONO
178178std::optional<time_point> localtime_to_utc (local_time_point dt, std::optional<choose> choice)
179179{
180- if (choice.has_value ()) {
181- return localtime_to_utc (zoned_time (std::chrono::current_zone (), dt, *choice));
182- } else {
183- return localtime_to_utc (zoned_time (std::chrono::current_zone (), dt));
184- }
180+ auto choiseVal = choice.value_or (choose::latest);
181+ return localtime_to_utc (zoned_time (std::chrono::current_zone (), dt, choiseVal), choiseVal);
185182}
186183
187- std::optional<time_point> localtime_to_utc (zoned_time zt)
184+ std::optional<time_point> localtime_to_utc (zoned_time zt, choose choice )
188185{
189186 auto localTimePoint = zt.get_local_time ();
190187
@@ -196,8 +193,12 @@ std::optional<time_point> localtime_to_utc(zoned_time zt)
196193 break ;
197194 }
198195 case std::chrono::local_info::ambiguous: {
199- Log::warn (" Ambiguous time point, taking the latest option" );
200- utcTime = std::optional<time_point>(i.second .begin );
196+ if (choice == choose::latest) {
197+ utcTime = std::optional<time_point>(i.second .begin - i.second .save );
198+ } else {
199+ assert (choice == choose::earliest);
200+ utcTime = std::optional<time_point>(i.first .end - i.first .save );
201+ }
201202 break ;
202203 }
203204 case std::chrono::local_info::nonexistent:
0 commit comments