Posts

Showing posts with the label ISO

ECMAScript 5 Full Specs String trim, trimLeft, and trimRight

During last evenings I have updated a little bit my vice-versa project . Since vice-versa aim is to bring in every browser what is possible to implement and, in most of the cases, already defined as standard (from W3 or MSDN when it is worthy) I decided to get rid of the Ariel Flesler fast trim proposal to introduce my lightweight full specs String.prototype.trim, trimLeft, and trimRight. For full specs I mean that vice-versa String.prototype.trim replace exactly same characters replaced by native Firefox 3.5 implementation, rather than only characters which code is less than 33 as is for Ariel proposal. The good part of vice-versa ( to be honest I cannot find bad parts so far ;) ) is that every single file is stand-alone, so if you do not like benefits the entire " lib " could bring, you can always adopt only one of its files, for example the String one, the Array one, or the last full specs ECMAScript 5 Date constructor , compatible with ISO strings, new Date("2009-0...

ECMAScript ISO Date For Every Browser

One most than welcome new entry of ECMAScript 5 is the Date.prototype.toISOString function and ability for Date constructor to accept an ISO String and to generate a Date instance. This feature will make JSON Date instances import/export extremely fast and simple, but why should we wait ES5 release when we can have both features now? Full Specs ISO 8601 Parser Plus Unobtrusive toISOString Method We all do not like that much to extend native JavaScript constructors, so here I am with a proposal that will not touch the Date prototype: if(!Date.ISO)(function(){"use strict"; /** ES5 ISO Date Parser Plus toISOString Method * @author Andrea Giammarchi * @blog WebReflection * @version 2009-07-04T11:36:25.123Z * @compatibility Chrome, Firefox, IE 5+, Opera, Safari, WebKit, Others */ function ISO(s){ var m = /^(\d{4})(-(\d{2})(-(\d{2})(T(\d{2}):(\d{2})(:(\d{2})(\.(\d+))?)?(Z|((\+|-)(\d{2}):(\d{2}))))?)?)?$/.exec(s); if(m === null) thr...