Skip to main content

Search and Top Navigation

#7954 closed feature (worksforme)

Opened December 14, 2011 01:59PM UTC

Closed December 14, 2011 02:22PM UTC

Last modified December 14, 2011 02:59PM UTC

Datepicker: Make date formatter stand-alone

Reported by: lxg 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.

Attachments (0)
Change History (2)

Changed December 14, 2011 02:22PM UTC by scottgonzalez comment:1

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.

Changed December 14, 2011 02:59PM UTC by lxg comment:2

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