Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: add/subtract with date!

From: brett:codeconscious at: 15-Nov-2000 15:17

Oops left in a couple of unnecessary "probes" at the end of my add-months function - just delete them. Also, while we are playing around with dates I thought I'd pass on another function too. Rebol allows you to add a time to a date. Like so
>> start-time: now
== 15-Nov-2000/15:13:59+11:00
>> end-time: start-time + 2:00
== 15-Nov-2000/17:13:59+11:00 But you cannot get the time interval using a simple operator (correct me if I'm wrong)
>> end-time - start-time
== 0 But using my datetime-subtract function you can
>> datetime-subtract end-time start-time
== 2:00 Here 'tis (expanded for readability) datetime-subtract: function [ "Subract one date from another returning time between them." a [date!] b [date!] ][delta-days delta-hhmmss a-hhmmss b-hhmmss] delta-days: subtract a/date b/date a-hhmmss: either a/time [a/time][00:00:00] b-hhmmss: either b/time [b/time][00:00:00] return add multiply 24:00:00 delta-days (subtract a-hhmmss b-hhmmss) ] Brett.