Comments (7)
Three questions:
1. Why is this better?
2. Does it add much code?
3. Is it a good idea to parse JSON differently than other libraries?
Original comment by [email protected]
on 11 Jul 2007 at 2:12
from base2.
1. Why is this better?
No information is thrown away. Now milliseconds, timezone offset and
daylightsavings offset are thrown
away. When creating a time zone-spanning website, that is accounted for.
2. Does it add much code?
Not much as you can see in the attached file (one extra function [pad3] and one
extra line). I use
getUTCFullYear instead of getFullYear, and so on for other date-parts.
According to http://
developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Date,
the all are introduced in
javascript 1.3 (so I don't need to do calculations).
I don't include timezone information in the date, although it's possible. I
think, this information is part of
locale-settings.
3. Is it a good idea to parse JSON differently than other libraries?
We're not parsing differently. A Date is serialized to a string. When read back
again, the string is still a string.
And when parsed, the string can always be truncated.
Original comment by [email protected]
on 11 Jul 2007 at 5:16
from base2.
You make a good case but I'd rather stay in synch with the official JSON spec.
This
is supposed to be a standards-based library after all.
Original comment by [email protected]
on 13 Jul 2007 at 6:00
Attachments:
from base2.
I agree. We're adding support when Douglas Crockford changes his library,
Firefox implements it, Ecmascript
4 is published or it appears in the Ecmascript 4 reference implementation.
Right?
In the mean time, i'll put my implementation in utils.
Besides, my implementation wasn't complete. The toISO proposal says the string
should be as short as
possible (omit time information from the right when it's zero). Also, it's not
clear on in what timezone it
should be serialized.
Links:
http://www.json.org/js.html
https://bugzilla.mozilla.org/show_bug.cgi?id=340987
http://developer.mozilla.org/es4/proposals/json_encoding_and_decoding.html
http://developer.mozilla.org/es4/proposals/date_and_time.html#iso_date_strings
http://www.ecmascript-lang.org/
Original comment by [email protected]
on 13 Jul 2007 at 7:32
from base2.
I've put the support in utils/Xstra/Date2.js as a Module.
JSON.Date.toString can refer to .toISO for the serialization.
Original comment by [email protected]
on 14 Jul 2007 at 4:53
from base2.
Original comment by [email protected]
on 14 Jul 2007 at 7:27
- Added labels: Browser-All, Module-base2.JSON
from base2.
Closing issue, awaiting standards.
Original comment by [email protected]
on 14 Jul 2007 at 7:31
- Changed state: WontFix
from base2.
Related Issues (20)
- Please add Array2.make HOT 2
- 'Unspecified error' when loading a page via iframe in IE8.
- Function.bind() defined in Firefox 4 conflicts with Base2's own bind()s. HOT 1
- base62 encoding shrinked script fails with 3.1 but works with 3.0 HOT 3
- Contact to the owner of the project? HOT 1
- DOMContentLoaded does not fire in Safari 3.0.4 (and possibly other versions) HOT 1
- IE throws "Unspecified Error" when calling some methods or accessing some properties of elements not attached to a document
- base2.jsb.eventDispatcher fails to dispatch (delegated?) events under IE9
- Listeners for (before)?(cut|copy|paste) events are not executed in IE7-9 HOT 1
- Patch for /trunk/src/apps/MiniWeb/Client.js
- Patch for /trunk/src/apps/MiniWeb/Client.js
- document not geting extended.
- getting opacity in getComputedPropertyValue of ViewCSS returns empty string on element without opacity set
- Eclipse "Syntax error on token "new", ArrayLiteralHeader expected after this token", l. 19 of v1.0.2 of base2.js HOT 3
- Consider relying on HTML ClassList API
- :checked pseudo-class doesn't match selected option elements.
- Non ascii strings broken when encoded HOT 1
- classList.remove can incorrectly trigger IE's onpropertychange event.
- Allow Base cast specialization HOT 1
- Patch for /trunk/src/apps/packer/Base62.js HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from base2.