Page 1 of 1

Date & Time utility functions

Posted: Mon Sep 26, 2022 6:17 pm
by Allanon
Hello all,
I want to share with you an include file with some utility functions/methods to deal with dates and times.
Methods are used with a date object and allow you to manipulate dates comparing, adding, subtracting them with other date objects.
It requires some additional libraries of mine that can be found on my github.

Contents

Code: Select all

FUNCTIONS
  DT.DateToDays(dd, mm, yy)
  DT.DaysToDate(days, format)
  DT.GetMonthDays(monthNum, year)
  DT.IsLeap(Year)
  DT.MillisecondsToTime(MS, decimal)
  DT.MinutesToTime(mins)
  DT.MonthToNumber(month)
  DT.NDate_AddDays(dd, mm, yy, days)
  DT.NumberToMonth(month)
  DT.SDate_AddDays(sDate, days)
  DT.SecondsToTime(secs)
  DT.TimeToMinutes(Tim)
  DT.TimeToSeconds(Tim)
  DT._anyToSeconds(arg)
  
OBJECTS/METHODS
  TimeObj:Add(tObj)
  TimeObj:New(timedef)
  TimeObj:NewFileLastChange(filename)
  TimeObj:NewNow()
  TimeObj:Sub(tObj)
  TimeObj:dbgPrint()
  TimeObj:equalTo(tObj, threshold)
  TimeObj:fromSeconds(seconds)
  TimeObj:fromString(s, mode)
  TimeObj:fromUnixTimeStamp(timestamp)
  TimeObj:greaterThan(tObj, threshold)
  TimeObj:lesserThan(tObj, threshold)
  TimeObj:toSeconds()
  TimeObj:toString(fmt)
  TimeObj:toUnixTimeStamp()

TESTS
  DT.TEST()
the source is full of comments & examples, including the

Code: Select all

DT.TEST()
function which is used to test the library but also as an example.

Github : https://github.com/Allanon71/Hollywood-MAL-Libraries

Happy coding! :)

Re: Date & Time utility functions

Posted: Mon Sep 26, 2022 7:22 pm
by Bugala
Thanks, this can be useful in many projects, would have been useful to me earlier this year, but already got that one done., but maybe on next one.