No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    DateUtils getMin/MaxDate is not working

    Framework
    4
    6
    300
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      ckoeste1 last edited by

      Hello!
      I tried to use the date utils from quasar and was trying the example of “Minimum/Maximum” from the docs. Copied it to my code and watched the result on the console. But the result is, for getMinDate: “Invalid Date” and for getMaxDate: “NaN”. I only copied the example code from the online docs and that is the result.
      Can anybody help me with this topic?
      Regards
      Chris

      1 Reply Last reply Reply Quote 0
      • s.molinari
        s.molinari last edited by

        Can you try making a codepen? https://codepen.quasar.dev

        Scott

        1 Reply Last reply Reply Quote 0
        • C
          ckoeste1 last edited by

          Hi Scott!
          Thanks for your reply. I have tried making the codepen but it seems so that it is not working as expected. I’m new to codepen and so I’m not sure what the problem is.
          I’ve used the following code in my project (it is directly from the quasar homepage):
          import { date } from ‘quasar’

          let dates = [ new Date(2017, 6, 24), new Date(2017, 5, 20), new Date(2017, 6, 26) ]
          let min = date.getMinDate(dates) // min is 2017-5-20
          let max = date.getMaxDate(dates) // max is 2017-6-26

          // Or simply use multiple parameters:

          let min = date.getMinDate(new Date(2017, 6, 24), new Date(2017, 5, 20), new Date(2017, 6, 26))
          // min is 2017-5-20
          let max = date.getMaxDate(new Date(2017, 6, 24), new Date(2017, 5, 20), new Date(2017, 6, 26))
          // max is 2017-6-26

          Regards
          Chris

          M 1 Reply Last reply Reply Quote 0
          • M
            mvelikoff @ckoeste1 last edited by

            Hi @ckoeste1,
            I think there is a mistake on the documentation or on the function implementation on dateUtils getMinDate and getMaxDate methods.
            If you pass “dates” parameter with spead (…) it works.
            In your case:
            let min = date.getMinDate(…dates) // min is 2017-5-20
            let max = date.getMaxDate(…dates) // max is 2017-6-26

            You can check more detailed on https://codepen.io/mvelikoff/pen/pozBzOy

            1 Reply Last reply Reply Quote 0
            • rstoenescu
              rstoenescu Admin last edited by

              It was a typo in docs. Correct usage:

              Minimum/Maximum

              To get the minimum/maximum date of a date set (i.e. array) use:

              import { date } from 'quasar'
              
              let min = date.getMinDate(new Date(2017, 6, 24), new Date(2017, 5, 20), new Date(2017, 6, 26))
              // `min` is 2017-5-20
              let max = date.getMaxDate(new Date(2017, 6, 24), new Date(2017, 5, 20), new Date(2017, 6, 26))
              // `max` is 2017-6-26
              
              // Or use an array:
              let dates = [ new Date(2017, 6, 24), new Date(2017, 5, 20), new Date(2017, 6, 26) ]
              let min = date.getMinDate(...dates) // `min` is 2017-5-20
              let max = date.getMaxDate(...dates) // `max` is 2017-6-26
              

              Note that the returning value is a timestamp.

              console.log(max) // 1497906000000
              console.log(new Date(max)) // Wed Jul 26 2017 00:00:00 GMT+0300 (Eastern European Summer Time)
              
              1 Reply Last reply Reply Quote 0
              • s.molinari
                s.molinari last edited by

                Here is a codepen to hopefully help understand. And thanks for asking here!

                https://codepen.io/smolinari/pen/bGbZXqL?editors=1010

                The docs will be corrected with the next update.

                Scott

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post