Giter Site home page Giter Site logo

JSON.Date.toString as UTC about base2 HOT 7 CLOSED

ideaovation avatar ideaovation commented on July 24, 2024
JSON.Date.toString as UTC

from base2.

Comments (7)

GoogleCodeExporter avatar GoogleCodeExporter commented on July 24, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 24, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 24, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 24, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 24, 2024
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.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 24, 2024

Original comment by [email protected] on 14 Jul 2007 at 7:27

  • Added labels: Browser-All, Module-base2.JSON

from base2.

GoogleCodeExporter avatar GoogleCodeExporter commented on July 24, 2024
Closing issue, awaiting standards.

Original comment by [email protected] on 14 Jul 2007 at 7:31

  • Changed state: WontFix

from base2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.