But it helps farmers ride the night trains to their fields in urban, crime-ridden retail districts of contemporary 19th century party cities! Do you hate them for their freedoms??
DST handling in client
Moderator: Project members
Re: DST handling in client
Yes. The unbelievable arrogance of these farmers, how dare they to make me change all my clocks all the time.btriffles wrote:But it helps farmers ride the night trains to their fields in urban, crime-ridden retail districts of contemporary 19th century party cities! Do you hate them for their freedoms??
- BradMarks
- 500 Command not understood
- Posts: 1
- Joined: 2013-12-11 23:03
- First name: Brad
- Last name: Marks
Re: DST handling in client
Do I gather correctly that this fix will be in the next general update of Filezilla?
Thanks!
Thanks!
Re: DST handling in client
Yes.BradMarks wrote:Do I gather correctly that this fix will be in the next general update of Filezilla?
Thanks!
Re: DST handling in client
I wrote some test code, and it appears that I was correct about the bug in Microsoft's localtime(). I hope the following code will help you avoid this problem in FileZilla:
Note that I tested this code outside of FileZilla and using wxWidgets 3.0, but I think it should be compatible.
Code: Select all
bool FormatDateTime(const wxDateTime &date, wxString &date_string)
{
// const wxString m_dateTimeFormat(_T("%A, %x %X")); // Get from FileZilla options
FILETIME ft_utc;
if (!ConvertWxDateTimeToFileTime(ft_utc, date))
return false;
// Convert from UTC to the local date/time, respecting the DST state of the date/time
SYSTEMTIME st_utc, st_local;
FILETIME ft_local;
if (!FileTimeToSystemTime(&ft_utc, &st_utc))
return false;
if (!SystemTimeToTzSpecificLocalTime(NULL, &st_utc, &st_local))
return false;
if (!SystemTimeToFileTime(&st_local, &ft_local))
return false;
// Convert the FILETIME struct to a tm struct, which strftime requires
wxDateTime time_local;
if (!ConvertFileTimeToWxDateTime(time_local, ft_local))
return false;
struct tm tm_local;
time_t ticks_local = time_local.GetTicks();
if (!wxGmtime_r(&ticks_local, &tm_local))
return false;
date_string = CallStrftime(m_dateTimeFormat, &tm_local); // Taken from wxWidgets' datetime.cpp
return true;
}