Problem with format in 'searchDateTime' columnControl

Problem with format in 'searchDateTime' columnControl

WernfriedWernfried Posts: 31Questions: 8Answers: 0

I use columnControl with searchDateTime content

columnControl: [
  'order',
  [
     { extend: 'searchDateTime', format: 'YYYYMMDD', excludeLogic: ['notEmpty', 'empty', 'notEqual'] },
  ]
]

DataTables throws an error:

Uncaught DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used

I use luxon in my page, function DateTime is available. Apart from that, format YYYYMMDD is valid according to ISO-8603, see https://en.wikipedia.org/wiki/ISO_8601 - it is called "basic format". DateTime.fromISO() accepts both formats (as momentjs, dayjs do also).

For me, it's a minor issue, no rush to fix it.

Kind Regards

Answers

  • WernfriedWernfried Posts: 31Questions: 8Answers: 0

    I get the same error also when I try to import

    import dtDateTime from 'datatables.net-datetime';
    

    Uncaught DateTime: Without momentjs, dayjs or luxon only the format 'YYYY-MM-DD' can be used

    I cannot use import DateTime from 'datatables.net-datetime'; as proposed in https://datatables.net/extensions/datetime/ because then I get a conflict:

    import { DateTime, Info } from 'luxon';
    import DateTime from 'datatables.net-datetime';
    

    SyntaxError: redeclaration of import DateTime

  • allanallan Posts: 65,821Questions: 1Answers: 10,951 Site admin

    When using ES modules try:

    DataTable.use(luxon);
    DataTable.use(DateTime);
    

    That will register both luxon (import * from 'luxon';) and DateTime with DataTables, since those packages aren't in a global scope and they don't have explicit dependencies.

    Interesting point about the YYYYMMDD format. I'll probably need to make a bunch of changes over the libraries to support that.

    Allan

Sign In or Register to comment.