Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

add-months and add-one-month functions

   1  
   2  add-months: func [
   3      date [date!]
   4      count [integer!] "Number of months to add"
   5      /local res
   6  ] [
   7      res: make date! reduce [date/day date/month + count date/year]
   8      ; If date/day is greater than the last day in the calculated
   9      ; month, we'll be at count+1 months, so we walk backwards until
  10      ; we find the last day of the previous month.
  11      while [(res/month - date/month) > count] [res: res - 1]
  12      res
  13  ]
  14  
  15  add-one-month: func [date [date!]] [add-months date 1]
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS