Skip to content

Fix: show the date a picker is set to - #858

Open
DTW-Thalion wants to merge 2 commits into
gnustep:masterfrom
DTW-Thalion:fix/datepicker-display
Open

Fix: show the date a picker is set to#858
DTW-Thalion wants to merge 2 commits into
gnustep:masterfrom
DTW-Thalion:fix/datepicker-display

Conversation

@DTW-Thalion

Copy link
Copy Markdown
Contributor

NSDatePickerCell set no format on its formatter, so the cell had nothing to draw from and fell back to the description of the date object. A picker showed a full date and time whatever its datePickerElements held, in the local time zone rather than the one it had been set to, in a form no locale writes.

The format is now built from the elements. Each element adds a letter to a template and the pattern generator returns the pattern that locale writes those elements in, and the format is rebuilt when the elements or the locale change. NSCell keeps the text its formatter made at the time the value was set, and -[NSDateFormatter stringForObjectValue:] builds that text from a %-style format rather than from the pattern, so -stringValue now comes from -stringFromDate:. A cell decoded without a formatter gets one.

A build without ICU has no pattern generator and gets a fixed field order instead. Editing a picker by keyboard or by clicking a calendar is not part of this.

Tests/gui/NSDatePicker/display.m has 7 assertions that fail before the change and pass after. Tests/gui/NSDatePicker and Tests/gui/NSDatePickerCell run 48 assertions green.

Refers to #95

NSDatePickerCell gave its formatter no format, so the cell had nothing
to draw from and fell back to the description of the date object. The
picker showed a full date and time whatever its datePickerElements were,
in the local time zone rather than the one it was set to, and in a form
no locale writes.

Build the format from the elements. Each element contributes a letter to
a template, and the pattern generator returns the pattern that locale
writes those elements in; a build without ICU has no generator and gets
a fixed order instead. The format is rebuilt whenever the elements or
the locale change.

NSCell keeps the text its formatter made at the time the value was set,
and -[NSDateFormatter stringForObjectValue:] builds that text from a
%-style format rather than from the pattern, so take -stringValue from
-stringFromDate: instead. A cell decoded without a formatter gets one,
as a cell built in code does.
START_SET creates an autorelease pool and END_SET releases it, so the pool
these tests create around the set is redundant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant