Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-4023

Add strict valid date support to Datebox without lenient mode

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Done
    • Icon: Normal Normal
    • 8.6.0
    • 8.5.2
    • None
    • Security Level: Jimmy
    • None
    • ZK 8.6.0 S1, ZK 8.6.0 S2

      In current datebox, if the user type a date that doesn't exist in the real calendar, it will automatically be calculated based on the closest existing date.
      for example:
      Jan 0 2018 = (Jan 1 2018) - (1day) = Dec 31 2017
      Jan 32 2018 = (Jan 31 2018) + (1day) = Feb 1 2018

      If a developper want to prevent this calculation, a partial solution is to use lenient=false on the datebox.
      However, this is not perfect, since lenient false will also prevent the datebox from trying to parse non-perfect template inputs

      New feature:
      Add a new attribute to the datebox to decide to allow for this calculation or not, not affected by lenient mode.
      for example:
      <datebox lenient="true" strictDate="true"/>
      would allow imperfect patterns, but block date calculation.

      <datebox lenient="false" strictDate="false"/>
      would only accept valid date patterns, but also allow calculation if the result is not a real world date. (0 Jan > 31 Dec, 32 Jan > 1 Feb, etc)

      Current calculation:
      https://github.com/zkoss/zk/blob/master/zul/src/archive/web/js/zul/db/datefmt.js#L394

            klyvechen klyvechen
            MDuchemin MDuchemin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 4 hours
                4h
                Remaining:
                Remaining Estimate - 4 hours
                4h
                Logged:
                Time Spent - Not Specified
                Not Specified