more G-Labs products

Author Topic: Date formatting  (Read 1868 times)

November 22, 2014, 10:11:56 PM
Read 1868 times

bradvoy

  • ***
  • Information
  • Full Member
  • Posts: 50
I am in the US where we expect to see dates in mm/dd/yy format.  The doorwindow widget displays the update time in dd/mm/yy format.  It looks like this is due to the following line in HG.WebApp.Utility.FormatDate (homegenie.webapp.js):

Code: [Select]
var dt = $.datepicker.formatDate('D, dd/mm/yy', date);
If I change this line to

Code: [Select]
var dt = date.toLocaleDateString();
then the date is displayed in the expected format.  Is this a change that could/should be incorporated into the code base?

November 22, 2014, 11:44:33 PM
Reply #1

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
Can you try with attacched file and tell if it's working?

Thanks,
g.
« Last Edit: November 23, 2014, 12:47:04 AM by Gene »

November 23, 2014, 09:37:01 PM
Reply #2

bradvoy

  • ***
  • Information
  • Full Member
  • Posts: 50
Gene, this code does not fix the problem because HG.WebApp.Locales.GetDateEndianType() doesn't handle negative timezone offsets from UTC correctly.  I am in the Mountain Standard timezone, which has an offset of -7 hours from UTC.  After the line

Code: [Select]
var testDate = new Date(98326800000);
testDate evaluates to 18:00 on 11 February 1973 in my timezone.  So localeDateParts[1] gets set to "11" and the function always returns 'L'.  It should return 'M' for my locale.

November 23, 2014, 09:46:22 PM
Reply #3

Gene

  • *****
  • Information
  • Administrator
  • Posts: 1472
  • Tangible is the future!
    • Yet Another Programmer
well let's test against the month part then =D

g.

November 24, 2014, 01:50:41 AM
Reply #4

bradvoy

  • ***
  • Information
  • Full Member
  • Posts: 50
This one works great.  Thanks for the quick fix.