UK Date Type Detection - dd/mm/yy

UK Date Type Detection - dd/mm/yy

sm9sm9 Posts: 27Questions: 0Answers: 0
edited May 2013 in General
Hi there,

I'd like to use the automatic type detection to detect UK dates in the format of dd/mm/yy.

I thought I'd found the solution on this site, but I noticed that the UK Date Type Detection plugin (http://www.datatables.net/plug-ins/type-detection) uses dd/mm/yyyy, whilst the closest UK Date sorting plugin I can find (http://www.datatables.net/plug-ins/sorting) uses dd/mm/yy.

Is there a solution that matches up for dd/mm/yy? Or can anyone tell me how I can modify the UK Date Type Detection plugin to detect dd/mm/yy rather than dd/mm/yyyy?

Thanks,

Stephen

Replies

  • essexstephessexsteph Posts: 57Questions: 0Answers: 0
    I think the issue is that the UK date detection relies on finding a final 4 digit year to confirm its dd/mm/yyyy. If all your dates are dd/mm/yy and no other data is in that format then I guess the plugin could be something like:

    [code]
    jQuery.fn.dataTableExt.aTypes.unshift(
    function ( sData )
    {
    if (sData !== null && sData.match(/..\/..\/../))
    {
    return 'date-uk';
    }
    return null;
    }
    );
    [/code]

    Steph
  • sm9sm9 Posts: 27Questions: 0Answers: 0
    edited June 2013
    Hi Steph,

    Sorry for the slow response to this - I've only just seen the email notification in my spam folder!

    Just tried this and it works a treat, so thanks for your help with this.

    It does make me wonder though - what use is the UK Date Type Detection plugin on this site if it doesn't have a matching sorting plugin, like the one you've provided above? I'm probably missing something. :-)

    Thanks again,

    Stephen
  • essexstephessexsteph Posts: 57Questions: 0Answers: 0
    Hi Stephen, glad to hear it's working. I think that the date-uk sorting plugin handles dd/mm/yy and dd/mm/yyyy but the detection plugin on the site only detected dd/mm/yyyy which is what caused your problem.

    Steph
  • sm9sm9 Posts: 27Questions: 0Answers: 0
    Hi Steph,

    Thanks for the clarification on that one. :-)

    Thanks,

    Stephen
This discussion has been closed.