Skip to content

Commit 6706ab4

Browse files
committed
Fix date-picker confusing American date format
Choosing a date with the calendar button, the selected date was hard-coded with "." as delimiter as "day.month.year". The later parsing interpreted this as "month/day/year" when the locale is set to e.g. US American. This fixes that by creating the date string according to the current locale. It's not really satisfying - as the whole date-handling back-forth between BDate and strings of the whole app feels wasteful... OTOH, adding another locale conversion here isn't that bad, as it's only invoked once for the date chosen in the calendar window... Fixes #129
1 parent 06b48fb commit 6706ab4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/CalendarButton.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*/
88
#include "CalendarButton.h"
99
#include "CalendarMenuWindow.h"
10+
#include "Database.h"
1011

1112
#include <Bitmap.h>
1213
#include <DateFormat.h>
@@ -55,7 +56,12 @@ CalendarButton::MessageReceived(BMessage* msg)
5556
msg->FindInt32("day", &day);
5657
msg->FindInt32("month", &month);
5758
msg->FindInt32("year", &year);
58-
date << day << "." << month << "." << year;
59+
60+
BDate thedate(year, month, day);
61+
BDateTime dateTime;
62+
dateTime.SetDate(thedate);
63+
gDefaultLocale.DateToString(dateTime.Time_t(), date);
64+
5965
fDateBox->SetText(date);
6066
fDateBox->Invoke();
6167
fDateBox->Validate();

0 commit comments

Comments
 (0)