Date and time functions

Moderator: Event DM

Post Reply
Papillon
Team Member; Retired with Honors
Posts: 3155
Joined: Thu Jul 18, 2002 11:17 pm
Contact:

Date and time functions

Post by Papillon » Sun Aug 04, 2002 11:43 pm

I wrote a small library for handling date and time values.

// Name : Date and time functions
// Author : Ingmar Stieger / Papillon
// Modified : August 04, 2002
// Version : 0.1

// Implemented datatype
// * DateTime

// Implemented functions
// * addDateTime() : Add two DateTimes
// * subDateTime() : Substract two DateTimes
// * compareDateTime() : Compare two DateTimes
// * getCurrentDateTime() : Return current DateTime
// * newDateTime() : Create new DateTime with given values
// * SetLocalDateTime() : Set oObject's local DateTime variable to date
// * GetLocalDateTime() : Get oObject's local DateTime variable
// * debugPrintDateTime() : Print DateTime for debugging purposes

// See function headers for details
//
// Example:
/* object oPC = GetPCSpeaker();

struct DateTime date1 = getCurrentDateTime();
struct DateTime date2 = newDateTime(0,0,0,8); // 8 hours later
struct DateTime finished = addDateTime(date1, date2);

SetLocalDateTime(oPC, "forge_shortsword_blade_finished", finished);
*/

--- cut

The source is too long to post here, but I've attached it as a .erf file.
User avatar
Silk
Co-Founder
Posts: 6662
Joined: Fri Sep 14, 2001 6:47 pm
Contact:

Post by Silk » Thu Aug 15, 2002 5:40 pm

You need to edit this a bit.

We don't want to store each variable seperately as a Persistant Variable.

Encode all the date/time variables into one deliminated string (don't use | pipes as a deliminator).

Then Make that set that string as persitant.

When your get the persistant string, simply decode the string into it's seperate date/time components.

The Persistant Date script get's too large too fast if you save 7+ variables every time for this functionality.

Otherwise, this code is very cool. I'll be using it for my tracking scripts.
Silk

Member of the MadK@t lover's group.
Papillon
Team Member; Retired with Honors
Posts: 3155
Joined: Thu Jul 18, 2002 11:17 pm
Contact:

Post by Papillon » Tue Aug 27, 2002 11:17 am

Updated version 0.2

* Date encoding added as suggested by Silk
User avatar
Silk
Co-Founder
Posts: 6662
Joined: Fri Sep 14, 2001 6:47 pm
Contact:

Post by Silk » Tue Aug 27, 2002 3:05 pm

schweet!!!
Silk

Member of the MadK@t lover's group.
Post Reply