Menu

#9 Datetime calculations

open
nobody
None
5
2002-08-15
2002-08-15
Tom Arn
No

Needed functions:
1. convert datetime into seconds
2. add / substract seconds to / from datetime to
calculate the new datetime

Discussion

  • Tom Arn

    Tom Arn - 2002-08-15

    Logged In: YES
    user_id=462273

    done:
    system.DateToFrame
    system.FrameToDate

    ex:
    Import "system"

    f1 = system.dateToFrame("17.08.02 00:00:00")
    f2 = system.dateToFrame("17.08.02 00:00:01")
    f3 = system.dateToFrame("17.08.02 00:00:40")
    f4 = system.dateToFrame("17.08.02 23:59:57")
    f5 = system.dateToFrame("17.08.02 23:59:58")
    f6 = system.dateToFrame("17.08.02 23:59:59")

    print f1,cr,f2,cr,f3,cr,f4,cr,f5,cr,f6,cr

    print system.FrameToDate(f3),cr
    print system.FrameToDate(f4),cr

    f3.datedays = f3.datedays + 2
    f3.timeseconds = f3.timeseconds + 3600
    print system.FrameToDate(f3),cr

     
  • A.H. Banen

    A.H. Banen - 2002-08-16

    Logged In: YES
    user_id=423153

    Tom,
    I may be nitpicking, but isn't there already a
    system.ParseTime(DateTimeString) that would make a new
    system.DateToFrame superfluous? The FrameToDate
    function however is a welcome addition; I personally would
    have called it something like FormatTime and make it use
    the same frame keys as are produced by ParseTime to
    avoid creating incompatible functions, as the date/time
    functions are already a little messy. Also it would be wise
    to use the frame output of ParseTime as a standard that
    can also be used with a forthcoming SetFileTime (wink,
    wink, nod, nod, Jim :)
    Andr

     
  • Jim

    Jim - 2002-08-29

    Logged In: YES
    user_id=406388

    I have added Tom's functions to the CVS as follows:

    Tom said"
    > I have now incorporated the new time functions into
    ParseTime and
    > CreateDate$
    >
    > The frame returned by ParseTime now contains additionally
    the values
    > 'datedays' and 'timeseconds'
    > CreateDate$ (why the $ sign???) now also accepts a frame
    containing
    > the values 'datedays' and 'timeseconds'
    >
    > Here's an example:
    >
    > Import "system"
    >
    > f1 = system.ParseTime("17.08.02 00:00:00")
    > f2 = system.ParseTime("17.08.02 00:00:01")
    > f3 = system.ParseTime("17.08.02 00:00:40")
    > f4 = system.ParseTime("17.08.02 23:59:57")
    > f5 = system.ParseTime("17.08.02 23:59:58")
    > f6 = system.ParseTime("17.08.02 23:59:59")
    >
    > print f1,cr,f2,cr,f3,cr,f4,cr,f5,cr,f6,cr
    >
    > print system.CreateDate$(f3),cr
    > print system.CreateDate$(f4),cr
    >
    > f3.timeseconds = f3.timeseconds + 3600
    > print system.Createdate$(f3),cr
    >
    > print (system.createdate$({datedays:423423,
    timeseconds:32}) =
    nil),cr

    "

     

Log in to post a comment.