Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
/*
	Copyright (c) 2004-2008, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


if(!dojo._hasResource["dojo.date.stamp"]){dojo._hasResource["dojo.date.stamp"]=true;dojo.provide("dojo.date.stamp");dojo.date.stamp.fromISOString=function(_1,_2){if(!dojo.date.stamp._isoRegExp){dojo.date.stamp._isoRegExp=/^(?:(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(.\d+)?)?((?:[+-](\d{2}):(\d{2}))|Z)?)?$/;}var _3=dojo.date.stamp._isoRegExp.exec(_1);var _4=null;if(_3){_3.shift();if(_3[1]){_3[1]--;}if(_3[6]){_3[6]*=1000;}if(_2){_2=new Date(_2);dojo.map(["FullYear","Month","Date","Hours","Minutes","Seconds","Milliseconds"],function(_5){return _2["get"+_5]();}).forEach(function(_6,_7){if(_3[_7]===undefined){_3[_7]=_6;}});}_4=new Date(_3[0]||1970,_3[1]||0,_3[2]||1,_3[3]||0,_3[4]||0,_3[5]||0,_3[6]||0);var _8=0;var _9=_3[7]&&_3[7].charAt(0);if(_9!="Z"){_8=((_3[8]||0)*60)+(Number(_3[9])||0);if(_9!="-"){_8*=-1;}}if(_9){_8-=_4.getTimezoneOffset();}if(_8){_4.setTime(_4.getTime()+_8*60000);}}return _4;};dojo.date.stamp.toISOString=function(_a,_b){var _=function(n){return (n<10)?"0"+n:n;};_b=_b||{};var _e=[];var _f=_b.zulu?"getUTC":"get";var _10="";if(_b.selector!="time"){var _11=_a[_f+"FullYear"]();_10=["0000".substr((_11+"").length)+_11,_(_a[_f+"Month"]()+1),_(_a[_f+"Date"]())].join("-");}_e.push(_10);if(_b.selector!="date"){var _12=[_(_a[_f+"Hours"]()),_(_a[_f+"Minutes"]()),_(_a[_f+"Seconds"]())].join(":");var _13=_a[_f+"Milliseconds"]();if(_b.milliseconds){_12+="."+(_13<100?"0":"")+_(_13);}if(_b.zulu){_12+="Z";}else{if(_b.selector!="time"){var _14=_a.getTimezoneOffset();var _15=Math.abs(_14);_12+=(_14>0?"-":"+")+_(Math.floor(_15/60))+":"+_(_15%60);}}_e.push(_12);}return _e.join("T");};}
New to GrepCode? Check out our FAQ X