Date manipulation: Difference between revisions
Content added Content deleted
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations.) |
|||
Line 1,789: | Line 1,789: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
This version only works with REXXes that support the ''' |
This version only works with REXXes that support the '''date''' and '''time''' extended functions. |
||
<lang REXX>/*REXX |
<lang REXX>/*REXX program adds 12 hours to a given date and time, displaying the before and after.*/ |
||
aDate = 'March 7 2009 7:30pm EST' |
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 aDate mon dd yyyy hhmm tz . /*obtain the various parts and pieces. */ |
|||
mins = mins + (12*60) /*add twelve hours to timestamp. */ |
|||
mins = time('M', hhmm, "C") /*get the number minutes past midnight.*/ |
|||
mins = mins + (12*60) /*add twelve hours to the 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*/ |
|||
days = mins % 1440 /*compute number of days added to dats.*/ |
|||
aBdays = date('B', dd left(mon,3) yyyy) /*number of base days since REXX epoch.*/ |
|||
nBdays = aBdays + days /*now, add the number of days added. */ |
|||
nDate = date(,nBdays, 'B') /*calculate the new date (maybe). */ |
|||
⚫ | |||
nTime = time('C', nMins, "M") /* " " " time " */ |
|||
⚫ | |||
/*stick a fork in it, we're all done. */</lang> |
|||
{{out}} |
{{out}} |
||
<pre style="overflow:scroll"> |
<pre style="overflow:scroll"> |