Jump to content

Date manipulation: Difference between revisions

m
→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations.
m (→‎{{header|REXX}}: added/changed comments and whitespace, changed indentations.)
Line 1,789:
 
=={{header|REXX}}==
This version only works with REXXes that support the   '''DATEdate'''   and   '''TIMEtime'''   extended functions.
<lang REXX>/*REXX pgmprogram to addadds 12 hours to a given date &and time, showingdisplaying the before &and after.*/
aDate = 'March 7 2009 7:30pm EST' /*the original or base date to be used.*/
 
parse var aDate mon dd yyyy hhmm tz . /*obtain the various parts&pieces*/
parse var minsaDate =mon dd yyyy time('M',hhmm,'C') tz . /*getobtain the #various parts minutesand pastpieces. midnight*/
 
mins = mins + (12*60) /*add twelve hours to timestamp. */
nMins = mins //= time('M', hhmm, "C") 1440 /*computeget #minthe intonumber same/nextminutes past daymidnight.*/
daysmins = mins %+ (12*60) 1440 /*computeadd twelve hours numberto ofthe days "added"timestamp.*/
nMins = mins // 1440 /*compute number min into same/next day*/
aBdays = date('B',dd left(mon,3) yyyy) /*# of base days since REXX epoch*/
nBdays days = aBdaysmins +% days 1440 /*now, add the # /*compute number of days "added" to dats.*/
nDateaBdays = date(,nBdays,'B'), dd left(mon,3) yyyy) /*calculatenumber theof newbase datedays (maybe)since REXX epoch.*/
nTimenBdays = time('C',nMins,'M')aBdays + days /* " " " time /*now, add the number "of days added. */
nDate = date(,nBdays, 'B') /*calculate the new date (maybe). */
say aDate ' + 12 hours ───► ' ndate ntime tz /*display new timestamp.*/
nTime = time('C', nMins, "M") /* " " " /*sticktime " a fork in it, we're done.*/</lang>
 
say aDate ' + 12 hours ───► ' ndate ntime tz /*display the new timestamp to console.*/
/*stick a fork in it, we're all done. */</lang>
{{out}}
<pre style="overflow:scroll">
Cookies help us deliver our services. By using our services, you agree to our use of cookies.