Jump to content

Proper number formatting


Artefaqs Corporation

Recommended Posts

Posted

It would be nice if numbers, like post tallies and such, were run through number_format() so that they look correct.  

It's OK to just push out the raw number when your forum has 11 or 15 posts.  But when you get to 583,382, the commas (or whatever your particular geography uses) are essential.

The bonus is that number_format() automatically changes based on server location (assuming it was set up correctly), so IPS doesn't have to bother parsing commas versus periods or parenthesis. 

Posted
1 hour ago, Mark said:

They should be. can you point out anywhere that isn't?

Using the default EN-US locale (as bundled with Debian at least), there is no thousands separator set.

Can you please not rely on locales to set date and number formats - there is no locale, and I did look quite hard, that uses the only logical date format to use online, "9(th) March 2016", and it's entirely plausible that, even if the language pack did come bundled with a thousands separator, you might want to change it - in Europe, they tend to use . as a thousands separator and , as a decimal separator, whereas space or ' would be unambiguous.

Posted

On this site it seems to be working fine:

56e05c541c861_ScreenShot2016-03-09at17.2

We use locales to format this data because, as you correctly point out, the correct format depends where you are.

Posted
14 minutes ago, Mark said:

On this site it seems to be working fine:

56e05c541c861_ScreenShot2016-03-09at17.2

We use locales to format this data because, as you correctly point out, the correct format depends where you are.

Yes, but this site is running on AWS, so I suspect you have a different language pack. The en-us language pack available for Debian Jessie does not include a thousands separator.

The correct format does indeed depend on where you are. However, a significant number (probably the majority, but I don't have any statistics to support that) of sites running a forum will be international. Date formats should be ambiguous - I hate finding a website that uses an ambiguous format and having to figure out what format it is probably in so that I can understand the dates. You have avoided ambiguous dates for most of the site by using relative dates and falling back to dd MMMM (YYYY) when that is too long ago, so why not just switch in the few places that still use the locale's default format? %d %b %y => 06 Mar 16, which is shorter than 03/06/2016. You can still truncate it further to Mar 16, as you already do (or at least have the HTML to support) with relative formats.

For date inputs in browsers that don't natively support them, ideally it would be possible to select the date format, so that the admin can select YYYY-MM-DD on international sites.

There are no English locales that support the unambiguous, universally understood, date formats.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...