Date & Time utility functions

Show off your project created with Hollywood
Post Reply
User avatar
Allanon
Posts: 732
Joined: Sun Feb 14, 2010 7:53 pm
Location: Italy
Contact:

Date & Time utility functions

Post 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! :)
Bugala
Posts: 1168
Joined: Sun Feb 14, 2010 7:11 pm

Re: Date & Time utility functions

Post 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.
Post Reply