This is distressing for me because I'm trying to use cookies on the client (JS) side, and Cookie class uses this method, if maxAge is set.
andyTue 14 Jun 2011
Promoted to ticket #1558 and assigned to andy
Yeah that one is missing. Java implementation uses SimpleDateFormat - which we obviously don't have in JavaScript - so need something to handle things at a lower level.
dsavThu 16 Jun 2011
But it's DateTime.fromHttpStr which uses SimpleDateFormat, not DateTime.toHttpStr.
toHttpStr can be easily implemented using code which is very similar to the Java one:
diff -r 3be227787f21 src/sys/js/fan/DateTime.js
--- a/src/sys/js/fan/DateTime.js Sun Jun 05 09:39:02 2011 -0400
+++ b/src/sys/js/fan/DateTime.js Thu Jun 16 12:23:15 2011 +0700
@@ -607,6 +607,16 @@
if (year < 1901 || year > 2099)
throw fan.sys.ArgErr.make("Year out of range " + year);
}
+
+//////////////////////////////////////////////////////////////////////////
+// HTTP
+//////////////////////////////////////////////////////////////////////////
+
+fan.sys.DateTime.prototype.toHttpStr = function()
+{
+ return this.toTimeZone(fan.sys.TimeZone.utc()).toLocale("WWW, DD MMM YYYY hh:mm:ss", fan.sys.Locale.fromStr("en")) + " GMT";
+}
+
//////////////////////////////////////////////////////////////////////////
// ISO 8601
//////////////////////////////////////////////////////////////////////////
I think, toHttpStr is useful even without fromHttpStr. E.g. Cookie uses it, and it doesn't use fromHttpStr.
May be, you could add toHttpStr implementation and close this issue, leaving fromHttpStr until later?
andyThu 16 Jun 2011
Ticket resolved in 1.0.60
Thanks @dsav - I pushed this change. Usually I like to add the toStr/fromStr at the same time - so we can get things passing the existing test suite - but this is such a simple fix its fine to just knock out.
dsav Tue 14 Jun 2011
This is distressing for me because I'm trying to use cookies on the client (JS) side, and
Cookie
class uses this method, if maxAge is set.andy Tue 14 Jun 2011
Promoted to ticket #1558 and assigned to andy
Yeah that one is missing. Java implementation uses SimpleDateFormat - which we obviously don't have in JavaScript - so need something to handle things at a lower level.
dsav Thu 16 Jun 2011
But it's
DateTime.fromHttpStr
which usesSimpleDateFormat
, notDateTime.toHttpStr
.toHttpStr
can be easily implemented using code which is very similar to the Java one:I think,
toHttpStr
is useful even withoutfromHttpStr
. E.g. Cookie uses it, and it doesn't usefromHttpStr
.May be, you could add
toHttpStr
implementation and close this issue, leavingfromHttpStr
until later?andy Thu 16 Jun 2011
Ticket resolved in 1.0.60
Thanks @dsav - I pushed this change. Usually I like to add the toStr/fromStr at the same time - so we can get things passing the existing test suite - but this is such a simple fix its fine to just knock out.