Wicket
  1. Wicket
  2. WICKET-751

DatePicker doesn't adhere to the provided DatePattern

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.3.0-beta2
    • Fix Version/s: 1.3.0-beta3
    • Component/s: wicket-datetime
    • Labels:
      None

      Description

      when a pattern like dd.MM.yy is used, the date is actually converted as if the pattern was d.M.yyyy
      this is due to the code in line 50 in DatePicker.js
      var val = '$

      {datePattern}

      '.replace(/d+/, dt).replace(/M+/, month).replace(/y+/, yr);

      the code should be changed, so that at least patterns like /dd+/, /MM+/ and /yy/ are supported.

        Activity

        Hide
        Eelco Hillenius added a comment -

        I would like to have the situation where we wouldn't be responsible for maintaining any localized strings.

        Show
        Eelco Hillenius added a comment - I would like to have the situation where we wouldn't be responsible for maintaining any localized strings.
        Hide
        Gerolf Seitz added a comment -

        do you really need to access the localized strings in java?
        since localization for the yui calendar has to be "manually" done (-> strings for names of days/months, ...) these are readily available on the javascript side (if the locale is supported by either wicket-datetime or maybe the user somehow), couldn't all localization stuff be done on the client? i'm a bit confused (no wonder at 2.00 am here in austria)

        can't we just use DatePickerSettings from wicket-contrib-datepicker? that would make it much easier.

        Show
        Gerolf Seitz added a comment - do you really need to access the localized strings in java? since localization for the yui calendar has to be "manually" done (-> strings for names of days/months, ...) these are readily available on the javascript side (if the locale is supported by either wicket-datetime or maybe the user somehow), couldn't all localization stuff be done on the client? i'm a bit confused (no wonder at 2.00 am here in austria) can't we just use DatePickerSettings from wicket-contrib-datepicker? that would make it much easier.
        Hide
        Eelco Hillenius added a comment -

        Btw, OT but I could use some help with WICKET-747. It's a bit sucky to test as I'm not sure how other people are configuring this widget's positioning.

        Show
        Eelco Hillenius added a comment - Btw, OT but I could use some help with WICKET-747 . It's a bit sucky to test as I'm not sure how other people are configuring this widget's positioning.
        Hide
        Eelco Hillenius added a comment -

        > but what if the date is shown in a label instead of a textbox (don't know if that is possible right now)?

        That's a good point. You feel like playing with it a bit? Output should work fine, it's the interpreting that is tricky to maintain, as those localized strings are hardly accessible in Java.

        > concering localization: the YUI datepicker itself can (somehow) easily be localized. you just have to set some properties. this has to be done per YUI datepicker instance. an example for a german and japanese localization can be found at the YUI calendar website.

        Yeah. Localization should be doable, and I think/ hope I set it up so that it can relatively easily be done. The problem is that we need people to support the languages, and as you can learn from e.g. jscalendar, this is hard to achieve, so you'll probably end up supporting just a couple of languages well, a couple half-baked and no support for most. Doesn't have to be that much of a problem though. You're welcome to start with this and supply a patch that works for German.

        > anyway, if you don't feel the need for it, i'll not take anymore of your precious time. i'm just glad the zeropadding is fixed (i only found the bug because of some german locale testing). thx for that.

        Hey no problem. Anything that makes this component close to perfect is welcome Thanks for helping.

        Show
        Eelco Hillenius added a comment - > but what if the date is shown in a label instead of a textbox (don't know if that is possible right now)? That's a good point. You feel like playing with it a bit? Output should work fine, it's the interpreting that is tricky to maintain, as those localized strings are hardly accessible in Java. > concering localization: the YUI datepicker itself can (somehow) easily be localized. you just have to set some properties. this has to be done per YUI datepicker instance. an example for a german and japanese localization can be found at the YUI calendar website. Yeah. Localization should be doable, and I think/ hope I set it up so that it can relatively easily be done. The problem is that we need people to support the languages, and as you can learn from e.g. jscalendar, this is hard to achieve, so you'll probably end up supporting just a couple of languages well, a couple half-baked and no support for most. Doesn't have to be that much of a problem though. You're welcome to start with this and supply a patch that works for German. > anyway, if you don't feel the need for it, i'll not take anymore of your precious time. i'm just glad the zeropadding is fixed (i only found the bug because of some german locale testing). thx for that. Hey no problem. Anything that makes this component close to perfect is welcome Thanks for helping.
        Hide
        Gerolf Seitz added a comment -

        yeah, you're probably right.
        but what if the date is shown in a label instead of a textbox (don't know if that is possible right now)?

        concering localization: the YUI datepicker itself can (somehow) easily be localized. you just have to set some properties. this has to be done per YUI datepicker instance. an example for a german and japanese localization can be found at the YUI calendar website.

        anyway, if you don't feel the need for it, i'll not take anymore of your precious time. i'm just glad the zeropadding is fixed (i only found the bug because of some german locale testing). thx for that.

        Show
        Gerolf Seitz added a comment - yeah, you're probably right. but what if the date is shown in a label instead of a textbox (don't know if that is possible right now)? concering localization: the YUI datepicker itself can (somehow) easily be localized. you just have to set some properties. this has to be done per YUI datepicker instance. an example for a german and japanese localization can be found at the YUI calendar website. anyway, if you don't feel the need for it, i'll not take anymore of your precious time. i'm just glad the zeropadding is fixed (i only found the bug because of some german locale testing). thx for that.
        Hide
        Eelco Hillenius added a comment -

        > i was actually thinking about "names of days and stuff".

        Stuff rocks. Names of days I don't know

        Seriously, it's not so much that I think it is impossible to do, but rather that I think it's hard to support all the languages there are. The way the date picker is set up currently, it should support the pattern of any locale out there. Unless resources for all the different days/ months/ etc are readily available someone (and with the right license), I think it's too much of a hassle.

        And then there is the question of whether it is useful in the first place. I think people will typically use the picker, but it's great that they can alternatively just type it as well. Tbh, I don't think anyone would prefer to type names of days and months to just using the numbers.

        Show
        Eelco Hillenius added a comment - > i was actually thinking about "names of days and stuff". Stuff rocks. Names of days I don't know Seriously, it's not so much that I think it is impossible to do, but rather that I think it's hard to support all the languages there are. The way the date picker is set up currently, it should support the pattern of any locale out there. Unless resources for all the different days/ months/ etc are readily available someone (and with the right license), I think it's too much of a hassle. And then there is the question of whether it is useful in the first place. I think people will typically use the picker, but it's great that they can alternatively just type it as well. Tbh, I don't think anyone would prefer to type names of days and months to just using the numbers.
        Hide
        Gerolf Seitz added a comment -

        i was actually thinking about "names of days and stuff". i already got it working with names of months. there aren't that many other date related fields, so maybe it wouldn't be that hard. and since the YUI datepicker only needs day (of month), month and year, all other date pattern elements would only have to be ignored in the string-to-date direction and be converted to the values (eg name of weekday) in the date-to-string direction.
        but it probably comes down to whether users would even need it.

        anyway, since the datepicker basically only works with a short date pattern (well, any variations of (d+, M+, yy+), maybe this should be mentioned in the javadocs of the datepicker somewhere.

        Show
        Gerolf Seitz added a comment - i was actually thinking about "names of days and stuff". i already got it working with names of months. there aren't that many other date related fields, so maybe it wouldn't be that hard. and since the YUI datepicker only needs day (of month), month and year, all other date pattern elements would only have to be ignored in the string-to-date direction and be converted to the values (eg name of weekday) in the date-to-string direction. but it probably comes down to whether users would even need it. anyway, since the datepicker basically only works with a short date pattern (well, any variations of (d+, M+, yy+), maybe this should be mentioned in the javadocs of the datepicker somewhere.
        Hide
        Eelco Hillenius added a comment -

        I'm almost done fixing this, I'll commit it in a sec.

        More patterns? Like names of days and stuff? That'd be very hard to maintain in a decent fashion, and I doubt it's something users have been waiting for. Or do you mean something else maybe?

        Show
        Eelco Hillenius added a comment - I'm almost done fixing this, I'll commit it in a sec. More patterns? Like names of days and stuff? That'd be very hard to maintain in a decent fashion, and I doubt it's something users have been waiting for. Or do you mean something else maybe?
        Hide
        Gerolf Seitz added a comment -

        hm, crap.
        but it doesn't matter that much, since i wanted to provide a patch that covers even more date patterns.
        sorry for wasting your time though. i will triple check it next time.

        Show
        Gerolf Seitz added a comment - hm, crap. but it doesn't matter that much, since i wanted to provide a patch that covers even more date patterns. sorry for wasting your time though. i will triple check it next time.
        Hide
        Eelco Hillenius added a comment -

        Cheers. Unfortunately, the patch doesn't work.

        Show
        Eelco Hillenius added a comment - Cheers. Unfortunately, the patch doesn't work.

          People

          • Assignee:
            Unassigned
            Reporter:
            Gerolf Seitz
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development