days_between_new_years.bmx 748 B

123456789101112131415161718192021222324
  1. SuperStrict
  2. ' calculates the number of days till new years.
  3. ' Provides a simple example of using a date generator, and simple
  4. ' mathematical operations, to calculate the days since
  5. ' New Years day of this year, and days until next New Years day.
  6. Framework Boost.DateTime
  7. Import BRL.StandardIO
  8. Local today:TDate = TDate.localDay()
  9. Local newYearsDay:TPartialDate = New TPartialDate(1, EMonth.January)
  10. ' Subtract two dates to get a duration
  11. Local daysSinceYearStart:Int = today.subtractDate(newYearsDay.getDate(today.year()))
  12. Print "Days since Jan 1: " + daysSinceYearStart
  13. Local daysUntilYearStart:Int = newYearsDay.getDate(today.year() + 1).subtractDate(today)
  14. Print "Days until next Jan 1: " + daysUntilYearStart