var Time={
D:{y:1970,m:"01",d:"01",h:"00",i:"00",s:"00",l:"00"},
F:['y','m','d','h','i','s','l','M','WC','WE'],
M:['','Jan','Feb','Mar','Apr','May','Jun',
'Jul','Aug','Sep','Oct','Nov','Dec'],
WC:['日','一','二','三','四','五','六'],
WE:['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
,
f:function (n,fm,b){
var i,t=new Date(n),w=t.getDay(),fmt=Object.keys(this.D)
n=t.toISOString().match(/\d+/g)
if(b){
for(i in fmt) fm=fm.split(fmt[i]).join(n[i])
}else{
for(i in fmt) fm=fm.split(fmt[i]).join(parseInt(n[i]))
}
fm=fm.split('w').join(w).split('WC').join(this.WC[w])
fm=fm.split('M').join(this.M[parseInt(n[1])])
return fm.split('WE').join(this.WE[w])
}
,
re:function (s,fm){
var i,p,t=this.F,pos={}
for(i in t){
p=fm.indexOf(t[i])
while(p>=0){
pos[p]=t[i]
p=fm.indexOf(t[i],p+t[i].length)
}
}
var p=Object.keys(pos),gap={}
p.push(fm.length)
for(i=p.length-2;i>=0;i--){
t=p[i]-0
gap[t]=fm.substring(t+pos[t].length,p[i+1])
}
s=s.substr(p[0]),t={}
for(i in gap){
p=s.indexOf(gap[i],1)
if(p>=0){
t[pos[i]]=s.substring(0,p)
s=s.substr(p+gap[i].length)
}else return null;
}
if(!t["m"] && t["M"]) t["m"]=this.M.indexOf(t["M"])
for(i in this.D){
if(!t[i]) t[i]=this.D[i]
else if(t[i].length<2) t[i]='0'+t[i]
}
t=t.y+'-'+t.m+'-'+t.d+'T'+t.h+':'+t.i+':'+t.s+'.'+t.u+'Z'
return new Date(t).valueOf()
}
}