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

[REBOL] Re: How to scale Date-Time properly in REBOL?

From: brett:codeconscious at: 14-Jan-2002 19:26

Hi Jason,
> what do you suggest?
You're probably not going to like this :) Ask [feedback--rebol--com]. *ducks* Other than that I've include just a few miscellanous functions I've used (not very often) just to feel like I contributed something of even small use: ; ; Datetimes ; subtract-datetimes: 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) ] ; ; Dates ; add-months: function [ "Add months to a date." date [date!] months [integer!] ] [result-date delta-years delta-months] [ delta-years: to-integer divide months 12 delta-months: remainder months 12 if lesser? delta-months 0 [ delta-years: subtract delta-years 1 delta-months: add delta-months 12 ] result-date: date result-date/year: add result-date/year delta-years result-date/month: add result-date/month delta-months return result-date ] first-day?: func [ "First day of the month." date "Specifies a month using an sample date." [date!] ][ to-date reduce[1 date/month date/year] ] days-in-month?: func [ "Number of days in the month." date "Specifies a month using an sample date." [date!] ][ subtract to-date reduce[1 date/month + 1 date/year] first-day? date ] last-day: last-day?: func [ "Last day of the month." date "Specifies a month using an sample date." [date!] ][ to-date reduce [ days-in-month? date date/month date/year] ] Cheers, Brett.