saheb11 / datejs

Automatically exported from code.google.com/p/datejs
Other
0 stars 0 forks source link

The ordinal suffix format specifier doesn't work. #148

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. console.log(new Date().toString("dS"));        

What is the expected output? What do you see instead?
Today the output should be "28th", but instead it's "28S".

What version of the product are you using? On what operating system?
 * Version: 1.0 Alpha-1 
 * Build Date: 13-Nov-2007

Please provide any additional information below.
The S is documented here: http://code.google.com/p/datejs/wiki/FormatSpecifiers

Original issue reported on code.google.com by iangilman on 28 Mar 2012 at 8:29

GoogleCodeExporter commented 8 years ago
Still happening to me as well.

Original comment by walkerde...@gmail.com on 19 Apr 2012 at 4:47

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Also happened to me. Here is my fix around it:

d = new Date(),
w = d.toString("dddd, MMMM dXXXX, yyyy"),
replace = d.getOrdinal();

w.replace("XXXX", replace);

Hope this helps. 

Original comment by fily.oli...@gmail.com on 11 Jul 2012 at 11:05

GoogleCodeExporter commented 8 years ago
Nice! Thanks. :-)

Original comment by iangilman on 12 Jul 2012 at 5:51

GoogleCodeExporter commented 8 years ago
Bug is still present, but this worked for me - thanks to the commenter above!

var d1 = Date.parse("tomorrow");
console.log( d1.toString("MMM d")+d1.getOrdinal() );

Outputs "Sep 15th"

Original comment by t...@jivebrew.com on 14 Sep 2012 at 2:29

GoogleCodeExporter commented 8 years ago
Same problem S outputs S.

Original comment by IainMNor...@gmail.com on 5 Feb 2013 at 5:08

GoogleCodeExporter commented 8 years ago
@#6IainMNor...@gmail.com

Follow my solution (#3). Seems to do the job. Not the best, but gets it sorted

Original comment by fily.oli...@gmail.com on 5 Feb 2013 at 5:09

GoogleCodeExporter commented 8 years ago
Easy (and not kludgy) fix for this.

On line 42 in date.js, FIND THE FOLLOWING TEXT:
case"d":return self.getDate().toString();

And ADD THIS BIT DIRECTLY AFTER IT:
case"S":return self.getOrdinal();

THEN, REPLACE (also on line 42):
/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g

WITH:
/dd?d?d?|S|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g

That's it! Works like a charm. :)

Original comment by hoffer....@gmail.com on 17 Apr 2013 at 2:36

GoogleCodeExporter commented 8 years ago
Looks like the author had just forgotten to put this in. :P

Original comment by hoffer....@gmail.com on 17 Apr 2013 at 2:37

GoogleCodeExporter commented 8 years ago
Awesome… At least we can all have the fix in our own versions. :-)

Original comment by iangilman on 18 Apr 2013 at 3:57

GoogleCodeExporter commented 8 years ago
works fine in the current build of my fork: 
https://github.com/abritinthebay/datejs/

(also works in the one in the SVN here).

Original comment by darkcr...@gmail.com on 16 Sep 2013 at 4:17

GoogleCodeExporter commented 8 years ago
Yeah, I guess this repo is just dead... no releases since 2007 (even if the bug 
is fixed in the source). Great to know about your fork!

Original comment by iangilman on 16 Sep 2013 at 9:53