[haiku-commits] Re: haiku: hrev51194 - src/kits/network/libnetapi

  • From: Adrien Destugues <pulkomandy@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 5 Jun 2017 15:40:50 +0200

2017-06-05 14:15 UTC+02:00, Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>:

Am 04/06/2017 um 07:52 schrieb pulkomandy@xxxxxxxxxxxxx:
     expirationTm.tm_mon = fDate.Date().Month() - 1;
     expirationTm.tm_year = fDate.Date().Year() - 1900;
-    expirationTm.tm_wday = fDate.Date().DayOfWeek();
+    // strftime starts weekday count at 0 for Sunday,
+    // while DayOfWeek starts at 1 for Monday and thus uses 7 for Sunday
+    expirationTm.tm_wday = fDate.Date().DayOfWeek() % 7;
     expirationTm.tm_yday = 0;

How about a BDateTime::Get(struct tm& tm) method?

There is the problem that a struct tm can be obtained ither from
gmtime (in which case it is in GMT), or localtime (in which case it is
in local time), and there is no way to know which one it is. For this
reason, BDateTime works with time_t, and expects you to convert timegm
to time_t using localtime() or gmtime(), depending on which timezone
is the source.

The cookie code, however, avoids time_t because there are cookies set
to expire after the year 2038 bug (mostly in test suites, but still,
it isn't that far in the future).

That being said, we could add the method, but with a warning that it
only handles one of the two cases.

-- 
Adrien Destugues / PulkoMandy
http://pulkomandy.tk

Other related posts: