Issues with date fields in dialogues

I've been experimenting with date fields in dialogues and have found what I
think is an anomaly. As I understand it, a date field is intended to hold a
single date in its model. This can be viewed when the dialogue is displayed.
Apart from initialising it within the editor, there are at least three ways
of setting this field :

1) by setting its Text property within a macro
2) by setting its Date property within a macro
3) by typing a date into the field.

However, if one uses (1), the Date property is not changed, if one uses (2)
the Text property is not changed, and if one uses (3) both properties are
changed. Surely both properties should follow the displayed view of the
field, however it is modified. Is this designed, or a bug?

It's only a problem if you try to set the property one way and read it the
other, so a workaround is possible.

Hello Peter,

I've been experimenting with date fields in dialogues and have
found what I think is an anomaly. As I understand it, a date field
is intended to hold a single date in its model. This can be viewed
when the dialogue is displayed. Apart from initialising it within
the editor, there are at least three ways of setting this field :

1) by setting its Text property within a macro 2) by setting its
Date property within a macro 3) by typing a date into the field.

However, if one uses (1), the Date property is not changed, if one
uses (2) the Text property is not changed, and if one uses (3) both
properties are changed. Surely both properties should follow the
displayed view of the field, however it is modified. Is this
designed, or a bug?

You could work with a view on the dialog and with the model. The view
only shows, what you could see on the screen. Could be there is some
content behind which will be saved if you press the SAVE-Button. The
model has content, which could be saved.

I don't know much about dialogs, in form-controls the text could be
changed and nothing would be saved by the database, because the value
of the control hasn't been saved.

If I will change a date in a form I write down
oDateField.BoundField.updateDate( unoDate )
and this changes both: The content I could see and the content behind
for the database. It works as typing it in the field.

Regards

Robert
- --
Homepage: http://robert.familiegrosskopf.de
LibreOffice Community: http://robert.familiegrosskopf.de/map_3

Hi Robert,

What you say is of course all true. But it's not to do with database records (my original experiments were in fact on a spreadsheet), but the data as held in the dialog(ue).

Your method (thanks again) of copying a UNO Date into the field works fine, as does changing the text. But the underlying data seems to be in two places at once - never good design :slight_smile: - and what you read depends on how it was written.

I'm trying to work out if this is part of the design of dialogues, or an unwanted side-effect (i.e. a bug). And I'm looking for guidance as to whether I should put it into bugzilla and see what happens.

Best regards,

Peter
mailto:lo@ptoye.com
www.ptoye.com

Andreas,

Thanks Andreas, that's very helpful. But it doesn't seem to cover the presentation and updating of date fields in dialogues (as opposed to cells in a spreadsheet), which was my concern. I've found some anomalies in this which I've reported as a minor bug.

Best regards,

Peter
mailto:lo@ptoye.com
www.ptoye.com

Hit the push button which is attached to the sheet. It opens a dialog with a
date and time control. The two controls read and write the A1 cell. It works
with all versions of Libre/OpenOffice and it works correctly with different
NullDate settings.
Function convertDateTime is designed to convert any type of date/time into
any other type of date/time.

[Tutorial] Date-Time Conversion in StarBasic
<https://forum.openoffice.org/en/forum/viewtopic.php?f=74&t=82181>
including a spreadsheet document and a Basic function which converts all
types of dates, times, timestamps into any other type. Date-times can be
represented by UNO structs, integers, doubles, Basic type Date, ISO-strings
and localized strings.