Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#7954 closed feature (worksforme)

Datepicker: Make date formatter stand-alone

Reported by: Alex Günsche Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.datepicker Version:
Keywords: Cc:
Blocked by: Blocking:

Description

jQuery UI Datepicker includes a very versatile, fully i10n'd and well-tested date formatter.

It would be very useful for other date-formatting needs, too. Unfortunately, the dateFormat() method needs an instance of a $.datepicker, which makes stand-alone usage impossible.

It would be great if you could rebuild the datepicker plugin in a way that the date-formatter can be used seperate from the datepicker widget.

The date formatter could then be something like

// takes an instance of JavaScript's Date()
DateFormatter = function(Date)
{
    this.format(formatString)
    {
        // do formatting
        return formattedString;
    }
}

var df = new DateFormatter(new Date(1323870924000));
alert(df.format('dd/mm/yy'));

This could be shipped within the jquery.ui.datepicker file. This way, it wouldn't make a difference for people upgrading, while adding a massive benefit for users who need a standalone date formatter.

Change History (2)

comment:1 Changed 7 years ago by Scott González

Resolution: worksforme
Status: newclosed

https://github.com/jquery/globalize

I'm closing this as worksforme because Globalize already exists. This could stay open as a ticket to have datepicker use Globalize, but doesn't look like the intent of the ticket and that's already happening with the rewrite.

comment:2 Changed 7 years ago by Alex Günsche

I agree. Thanks for pointing me to Globalize, I wasn't aware that one.

Note: See TracTickets for help on using tickets.