DST handling in client

Moderator: Project members

Message
Author
btriffles
504 Command not implemented
Posts: 9
Joined: 2013-12-01 04:03

Re: DST handling in client

#16 Post by btriffles » 2013-12-07 23:07

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??
:wink:

User avatar
botg
Site Admin
Posts: 35566
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: DST handling in client

#17 Post by botg » 2013-12-08 07:31

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??
:wink:
Yes. The unbelievable arrogance of these farmers, how dare they to make me change all my clocks all the time.

User avatar
BradMarks
500 Command not understood
Posts: 1
Joined: 2013-12-11 23:03
First name: Brad
Last name: Marks

Re: DST handling in client

#18 Post by BradMarks » 2013-12-11 23:18

Do I gather correctly that this fix will be in the next general update of Filezilla?
Thanks!

User avatar
botg
Site Admin
Posts: 35566
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: DST handling in client

#19 Post by botg » 2013-12-12 07:22

BradMarks wrote:Do I gather correctly that this fix will be in the next general update of Filezilla?
Thanks!
Yes.

btriffles
504 Command not implemented
Posts: 9
Joined: 2013-12-01 04:03

Re: DST handling in client

#20 Post by btriffles » 2013-12-15 13:42

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:

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;
}
Note that I tested this code outside of FileZilla and using wxWidgets 3.0, but I think it should be compatible.

Post Reply