jsch / datejs

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

rfc1123 is wrongly formatted by toString #121

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Date.parse('Thu Jan 20 19:49:15 +0000 2011').toString('r')

What is the expected output? What do you see instead?

Expected: Wed, 20 Apr 2011 19:49:15 GMT
Obtained: Wed, 20 Apr 2011 19:49:15 G4T

What version of the product are you using? On what operating system?

SVN. Linux + Firefox 4.

Please provide any additional information below.

toString uses a regex to replace placeholders in the given format. rfc1123 
format (param 'r' passed to toString) contains a trailing 'GMT', which 'M' is 
erroneously matched as month, and replaced by the month number, rendering a 
wrong data.

Many solutions can be applied:

- modify the regex to ignore 'GMT'.
- remove 'GMT' from the rfc1123 format string, and prepend it to the resulting 
formatted string before returning it.

Original issue reported on code.google.com by aitorc...@gmail.com on 4 Apr 2011 at 8:27

GoogleCodeExporter commented 9 years ago
Seeing the same incorrect behaviour here... I guess enabling support for custom 
strings inside custom format would solve the problem, as well as enable one to 
write format strings such as '""HH:mm:ss" yyyy-MM-dd'.

Original comment by dawid.ci...@gmail.com on 6 Dec 2011 at 3:23