cosmocode / dokuwiki-plugin-struct

A new structured data plugin
https://www.dokuwiki.org/plugin:struct
GNU General Public License v2.0
40 stars 40 forks source link

Date picker ignores date format specified in schema #409

Open psy-q opened 6 years ago

psy-q commented 6 years ago

In my schema I set the date format "Y-m-d", but when using the field in a struct_field this format is ignored and the picker instead uses some American m/d/Y format. It also starts the week on Sunday instead of Monday as it should.

Schema and Bureaucracy form below, and here's a screenshot using Firefox 61.0.2:

screenshot_20180829_111308

{
    "structversion": "2018-08-06",
    "schema": "protokolle",
    "id": "29",
    "user": "_REDACTED_",
    "config": {
        "allowed editors": "",
        "label": {
            "de": "Protokolle"
        }
    },
    "columns": [
        {
            "colref": 1,
            "ismulti": false,
            "isenabled": false,
            "sort": 10,
            "label": "name",
            "class": "Text",
            "config": {
                "visibility": {
                    "inpage": true,
                    "ineditor": true
                },
                "prefix": "",
                "postfix": "",
                "label": {
                    "de": ""
                },
                "hint": {
                    "de": ""
                }
            }
        },
        {
            "colref": 2,
            "ismulti": true,
            "isenabled": true,
            "sort": 20,
            "label": "itzgroups",
            "class": "Dropdown",
            "config": {
                "visibility": {
                    "inpage": true,
                    "ineditor": true
                },
                "values": "Betrieb 1, Betrieb 2, Entwicklung, Planung",
                "label": {
                    "de": "ITZ-Gruppen"
                },
                "hint": {
                    "de": ""
                }
            }
        },
        {
            "colref": 3,
            "ismulti": false,
            "isenabled": true,
            "sort": 30,
            "label": "date",
            "class": "Date",
            "config": {
                "visibility": {
                    "inpage": true,
                    "ineditor": true
                },
                "format": "Y-m-d",
                "prefilltoday": false,
                "label": {
                    "de": "Datum"
                },
                "hint": {
                    "de": "Wann hat die Sitzung stattgefunden?"
                }
            }
        }
    ]
}

Bureaucracy data:

<form>
Fieldset "Neues Protokoll erstellen"
Action template templates:@@Vorlage@@ protokolle: "_" 
Thanks    "Protokoll wurde erstellt und kann gefüllt werden"

Static "Bitte die teilnehmenden Gruppen, Vorlage, und Datum der Sitzung wählen:"
struct_field "protokolle.itzgroups"

select "Vorlage" "protokolle|protokoll_abteilungssitzung|_REDACTED_" @
struct_field "protokolle.date" @

Submit
</form>
splitbrain commented 5 years ago

Does this happen in bureaucracy only? Or is this a problem when editing the struct fields on it's own as well?

fschrempf commented 3 years ago

To me it looks like the date format specified in the schema is ignored and instead the format depends only on the browsers locale setting. The behavior is the same in the bureaucracy form and in the struct editor.

vic-t commented 3 years ago

I just ran across the same issue and posted a bug report in the issue tracker for bureaucracy, see https://github.com/splitbrain/dokuwiki-plugin-bureaucracy/issues/291. That was too quick though, the bug seems to be in the struct plugin.

@splitbrain I can confirm that this is not happening just in bureaucracy but also when editing struct fields. Specifically, I have a schema that holds a date field assigned to a page. My global DW date format settings are d.m.Y, my date field config in the struct schema is also d.m.Y and this is the way struct presents the date field both on the page as well as in an aggregation. But when editing the date field, in the aggregation or in the page, the format changes to m/d/Y. So it's not just a matter of dots being replaced by slashes, the whole date structure changes.

Having tested it just now, I can confirm @fschrempf 's finding that the date formatting seems to depend on the browsers locale setting. Specifically, when I change my browser language from English to German, editing the date field in the struct gives me the desired d.m.Y formatting.