Date format

113 views
Skip to first unread message

Sarah Matthews

unread,
Jul 24, 2012, 8:55:28 PM7/24/12
to opentrippl...@googlegroups.com
Morning Guys

I changed the data format in Forms.js file makeDateTime function to d/m/y, looks fine in the plan journey form, however it return me error when I try to plan the journey because the opentripplanner-api-webapp still using m/d/y format.

Any one know is any other files I need to change, please?

Many Thanks

S

FrankP

unread,
Jul 25, 2012, 3:38:07 AM7/25/12
to opentrippl...@googlegroups.com
Hey Sarah, 

config.js is the place to make such changes.  BTW, the goal of config.js is that it's the single place where customization changes like date format, etc... are made (and I don't recommend mucking with Forms.js or other .js files beyond config.js, unless you're adding new functionality).

Anyway, to change the date format, add the following to config.js at about line 14:

otp.config.locale.time.date_format = "d/m/y";   (to be extra thorough, you can also override your chosen locale's date_format, ala otp.locale.English.time.date_format = "d/m/y").  

BTW, there are two other date / time related format fields to be overridden (and changing those should change date / time formats across the web app):

otp.config.locale.time.format = "d/m/y @ H:i";

otp.config.locale.time.time_format = "H:i";


Take care,

Frank



FrankP

unread,
Jul 25, 2012, 4:57:32 AM7/25/12
to opentrippl...@googlegroups.com
BTW, I added an otp.locale.English_UK.js to the mix as an alternate to what's in English.js (with the only difference right now being the date & time formats).  If there are any other changes (both date formats, and/or string localizations) you'd like to make to English_UK.js Sarah, send them along or check them into a github fork.


On Tuesday, July 24, 2012 5:55:28 PM UTC-7, Sarah Matthews wrote:

Wombatoo

unread,
Jul 25, 2012, 10:29:06 PM7/25/12
to opentrippl...@googlegroups.com
Thanks Frank :P

Tried just now, put the code into config.js file as below:

// step 1: make sure we have some type of otp.config, and otp.config.local defined
if(typeof(otp) == "undefined" || otp == null) otp = {};
if(typeof(otp.config) == "undefined" || otp.config == null) otp.config = {};
if(typeof(otp.config.locale) == "undefined" || otp.config.locale == null) otp.config.locale = otp.locale.English;

otp.config.locale.time.date_format = "d/m/y";
otp.config.locale.time.format = "d/m/y @ H:i";
otp.config.locale.time.time_format = "H:i";

// step 2: create an object of default otp.config default values (see step3 where we apply this to any existing config


However, the date format still not change on the form and param on the url ...

Any idea, please ?

Sarah Matthews

unread,
Jul 25, 2012, 10:34:50 PM7/25/12
to opentrippl...@googlegroups.com
Me 2, tried yesterday but also not working for me.

Just think maybe we're using the old otp version. Which version ur using at moment ?

Frank Purcell

unread,
Jul 25, 2012, 10:40:28 PM7/25/12
to Sarah Matthews, opentrippl...@googlegroups.com
Weird.  I'm using the latest code from head, but can't imagine that change wouldn't work fom many versions back (but I did fix a time bug on the intone tart yesterday).  Other option is editing English.js directly (but that's not good long term as it bound to change on the future).  

Sarah Matthews

unread,
Jul 26, 2012, 12:08:29 AM7/26/12
to opentrippl...@googlegroups.com, Sarah Matthews
Yes....

I just check my English.js - and it looks really old version - no "date_format" inside time section ....

So... if I add "date_format" into the time section like this:

time:
    {
        minute         : "minute",
        minutes        : "minutes",
        minute_abbrev  : "min",
        minutes_abbrev : "mins",
        second_abbrev  : "sec",
        seconds_abbrev : "secs",
        format         : "js F Y @ g:ia",
        date_format    : "j/n/Y",
        months         : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },


Is any files I need to change, please?

xxxx

Frank Purcell

unread,
Jul 26, 2012, 3:50:10 AM7/26/12
to Sarah Matthews, opentrippl...@googlegroups.com, Sarah Matthews
In this case, you would need to upgrade to the latest code.   Not having date format in your code means that things are probably hard wired all over the place...upgrade and you'll benefit from having a single place to change dates (and a few other benefits since).  
Reply all
Reply to author
Forward
0 new messages