Date manipulation: Difference between revisions

Content deleted Content added
Line 1,820: Line 1,820:
=={{header|zkl}}==
=={{header|zkl}}==
The iso8601 library offers additional Time/Date support but using the built in stuff:
The iso8601 library offers additional Time/Date support but using the built in stuff:
<lang zkl>var D=Time.Date;
<lang zkl>var Date=Time.Date;
fcn add12h(dt){
fcn add12h(dt){
re:=RegExp(0'|(\w+)\s+(\d+)\s+(\d+)\ +(.+)\s|);
re:=RegExp(0'|(\w+)\s+(\d+)\s+(\d+)\ +(.+)\s|);
Line 1,828: Line 1,828:
h,m,s:=Date.parseTime(hms); //19,30,0
h,m,s:=Date.parseTime(hms); //19,30,0
dti:=T(Y,M,D, h,m,s).apply("toInt");
dti:=T(Y,M,D, h,m,s).apply("toInt");
Y,M,D, h,m,s = Date.addHMS(dti,12);
Y,M,D, h,m,s=Date.addHMS(dti,12);
"%s %d %d %s".fmt(Date.monthNames[M],D,Y,Date.toAMPMString(h,m));
"%s %d %d %s".fmt(Date.monthNames[M],D,Y,Date.toAMPMString(h,m));
}</lang>
}
<lang zkl>add12h("March 7 2009 7:30pm EST").println();</lang>

add12h("March 7 2009 7:30pm EST").println();</lang>
{{out}}<pre>March 8 2009 07:30AM</pre>
{{out}}<pre>March 8 2009 07:30AM</pre>