Skip to content

date utils: getMaxDate / getMinDate return number instead of Date object #18260

@Kundan-CR7

Description

@Kundan-CR7

What happened?

The getMaxDate and getMinDate utilities return a numeric timestamp instead of a Date object.

This leads to runtime errors when using Date methods directly:

const result = date.getMaxDate(d1, d2)

console.log(typeof result) // number
console.log(result instanceof Date) // false

result.getFullYear() // TypeError

What did you expect to happen?

The function should return a Date object, consistent with other date utilities in Quasar.

Reproduction URL

https://codepen.io/KundanAIE/pen/zxKEZGR

How to reproduce?

  1. Open the reproduction link
  2. Run the code
  3. Observe that:
    • The returned value is a number
    • instanceof Date is false
  4. Calling getFullYear() throws a TypeError

Flavour

Quasar CLI with Vite (@quasar/cli | @quasar/app-vite)

Areas

Composables (quasar)

Platforms/Browsers

Chrome

Quasar info output

Relevant log output

Additional context

Root cause:
Math.max() and Math.min() convert Date objects to timestamps and return a number.

Suggested fix:
Wrap the return value in new Date(...) to maintain consistency.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions