Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2014-04-23 15:01:51

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Date format support

I’m sure this has been discussed before. But since we are not a US-centric CMS (the original founder was Canadian and all the current devs are European) we should really offer the article date fields in more options than just YYYY MM DD I think. Maybe as a pref option, or (better I think) via language/locale stuff.

Also, there are of course other calendars than Gregorian, Oleg did some great work with this plugin so I wonder if any of that could find its way into core? I’m still improving RTL language support within Textpattern so that would make sense to do.

Offline

#2 2014-04-23 15:58:23

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: Date format support

Not quite sure how we’d refactor the current article date fields to achieve this. Maybe better is to drop the three separate input fields in favour of a single box + date picker. Presumably, that’s nicer for mobile users too, as you get the date input widget instead of three separate number widgets? I would expect the jQuery UI date picker can be made locale (and date system???) aware. Behind the scenes we’d convert everything to UTC for storage but changing the date system would likely require a pref.

On this note, one of the things on my todo list is to investigate adding a ‘custom’ entry to the date format prefs so you can design your own (output) formats for articles using strftime() codes. That’s what the DB stores anyway so allowing custom formats seems fairly trivial on the surface.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2014-04-23 16:02:33

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Date format support

Well, we already have the jQuery UI datepicker widget available in the core, so that’s a good possibility.

There’s also HTML5 input types that deal with date and time – but browser support for those is still too patchy to rely on.

Offline

#4 2014-04-23 23:54:48

MattD
Plugin Author
From: Monterey, California
Registered: 2008-03-21
Posts: 1,254
Website

Re: Date format support

I wrote a plugin long ago that uses the jQuery UI datepicker for the article dates. But it does it all via javascript so not much help for a core implementation. msd_admin_datepicker

Last edited by MattD (2014-04-23 23:59:09)


My Plugins

Piwik Dashboard, Google Analytics Dashboard, Minibar, Article Image Colorpicker, Admin Datepicker, Admin Google Map, Admin Colorpicker

Offline

#5 2014-04-24 00:54:55

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: Date format support

Bloke wrote #280365:

Maybe better is to drop the three separate input fields in favour of a single box + date picker.

Exactly like that. Of course jQuery UI date widget, and HTML5 implementations in general, do support date and time in same field. So, basically there would be two bits of information, so will have to use two separate fields. Implementing the datepicker is easy. You would have implement some extra stuff such as:

  • passing dates with textpattern.gTxt() to the calendar…
  • …and in PHP passing them from locales to JavaScript through gTxtScript().
  • and adding some data- attribute support for controlling min/max date (which is merely one line of code).

E.g.

jQuery.fn.txpDatepicker = function (options)
{
    var minDate = this.attr('data-txp-mix-date').split('-');

    options = $.extends({
        monthNames: [textpattern.gTxt('january'), textpattern.gTxt('february')],
        minDate: new Date(minDate[0], minDate[1], minDate[2])
    }, options);

    this.datepicker(options);

    return this;
};

Resulting PHP implementation is easy to do too:

$date = new DateTime(ps('posted_date') + ' ' + ps('posted_time'));

…and you can input the date in any valid format and it will just work.

Last edited by Gocom (2014-04-24 00:58:13)

Offline

#6 2014-04-24 07:37:08

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: Date format support

Can one if you developer people do that then, when you have some spare time? I’ll do any extra styling needed after it’s patched in.

Offline

Board footer

Powered by FluxBB