External Links

Creative Science Centre

 

Library DandT

// #include "http://www.byvac.com/mBlib/flb/Library/2016/lib_dt.bas"  [0]

// #include "http://www.byvac.com/mBlib/flb/Library/2016/lib_dt_1.bas"  [1]

[0] has Julian data and time functions
[1] has unix UTC functions - use this one
 

Useful data and time functions can be used in conjunction with the RTC or WiFi.

Three formats are used

  • String format "Mon, 3 Aug 2016 12:33:19"
  • UTC number of seconds from Epoch 1/1/197
  • Array format, see below

// Time array format
// 0 year full 2016
// 1 month 1 to 12
// 2 day of month 1 to 31
// 3 day of week 1 to 7 (monday = 1)
// 4 hours
// 5 minutes
// 6 seconds
constant time.YEAR   0
constant time.MONTH  1
constant time.DOM    2
constant time.DOW    3
constant time.HOURS  4
constant time.MINS   5
constant time.SEC    6
// requires an array dom tm(8)

All time is stored internally in this array, the host or calling function must provide the array storage. Using the array is compatible with the I2C, RTC DS1307.

  • dt.time(webstring$[80],*tm()) // converts a web string to a time array
  • dt.web$(*tm()) // converts the time array to a web string
  • [0]
  • dt.jDayn(*tm()) // returns the Julian day number
  • dt.jn2day(jd,*tm()) // converts a Julian day number to day, month, year
  • dt.j2sec(*tm()) // number of seconds from base date to now if tm() is now
  • dt.sec2dt(sec,*tm()) // number of seconds back to time
  • [1]
  • dt.bst$(webstring$) // converts web string to a web string adjusts for BST if required
  • dt.UTC(*tm()) // converts time() to UTC
  • dt.UTC2time(utc,*tm()) // converts UTC to time()
  • dt.dayNumber(*tm()) // gets number of days since Epoch
  • dt.dow(*tm()) // gets day of week 1 to 7, 1 is Monday
  • dt.daylight(*tm()) // returns 1 if British summer time (used in dt.bst$(string$))