| View previous topic :: View next topic |
| Author |
Message |
gerrit Newbie

Joined: 14 May 2004 Posts: 24
|
Posted: Tue Apr 05, 2005 9:25 am Post subject: Date Convertion and Calculation? |
|
|
Hi all,
have a small problem with understanding the Convertion of a date Format..
I wrote something to Log Time and Date, something like
| Code: |
%%dtIn = @timedate(ENCODEDT,20%%Year,%%Month,%%Day,%%Std,%%Min,%%Sec)
%%dtOut = @timedate(ENCODEDT,20%%OutYear,%%OutMonth,%%OutDay,%%OutStd,%%OutMin,%%OutSec)
%%TimeConv = @timedate(DiffVDS, %%dtOut,%%dtIn)
|
Thanks to Dread's Timedate... very usefull
The result should be the Difference between the two Values, but I get something like 0|0|0|10|12|0|0000|.....
How can I convert this Value to the funky time Format? --> (123456.123456)
And I f I understand it right in this funky Format I can add the Date part and the Time part together and get a propper date with @DATETIME(<format-string> , <time-value> ) ??
Thanks to all,
Gerrit
| Code: | 1 whole number = 24hrs = 1440 mins = 86400 seconds
1 hour = .041666668
1 minute = .00069444447
1 second = .0000115740745 |
_________________ ___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________ |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Apr 05, 2005 11:33 am Post subject: Re: Date Convertion and Calculation? |
|
|
| gerrit wrote: |
have a small problem with understanding the Convertion of a date Format..
I wrote something to Log Time and Date, something like
| Code: |
%%dtIn = @timedate(ENCODEDT,20%%Year,%%Month,%%Day,%%Std,%%Min,%%Sec)
%%dtOut = @timedate(ENCODEDT,20%%OutYear,%%OutMonth,%%OutDay,%%OutStd,%%OutMin,%%OutSec)
%%TimeConv = @timedate(DiffVDS, %%dtOut,%%dtIn)
|
Thanks to Dread's Timedate... very usefull
The result should be the Difference between the two Values, but I get something like 0|0|0|10|12|0|0000|.....
|
That is the difference.... Difference is output in a |-separated unit: Years|Months|Days|Hours|Mins|Secs|Msecs
You can use PARSE to extract the various values.
| gerrit wrote: |
How can I convert this Value to the funky time Format? --> (123456.123456) |
Why would you want to convert the time diff into a VDS value? You cannot make any sensible VDS date with only
some time fractions. Perhaps you should give a hint of what exactly you're trying to do...
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
gerrit Newbie

Joined: 14 May 2004 Posts: 24
|
Posted: Tue Apr 05, 2005 12:15 pm Post subject: |
|
|
I wrote a Media Management tool for Film Productions, and when someone moves material local I write a small Log what he's doing. Now (worst case) there are scenes Dropped from the Film, and we need to calculate the time of the unfinished scenes.
The Log looks like this
| Code: | 01-28-05|12-40-28|System|Logged Out by|rouven|1
02-01-05|17-27-18|System|Logged in Complete by|rouven|0
02-15-05|15-37-33|System|Logged Out by|rouven|1
02-16-05|17-00-13|System|Logged in Complete by|rouven|0
02-16-05|17-33-54|System|Logged Out by|rouven|1
03-02-05|16-27-58|System|Logged in Complete by|rouven|0 |
Well and here is some of the Spagetti Code...
| Code: | If @Equal(%%Switsh,1)
%%TimeConv = @timedate(DiffVDS, %%dtOut,%%dtIn)
Option fieldsep,|
Parse "%%Year;%%Day;%%Month;%%Std;%%Min;%%Sec",%%TimeConv |
I think here is something Wrong.... ?
| Code: | | %%TimeConv = @timedate(UNIX, %%Year,%%Day,%%Month,%%Std,%%Min,%%Sec,0) |
| Code: | | List add,Output,%%TimeConv |
After adding all the Values to the Output List I want to add all the Differences together, and should get the Time a user spend on the scene....
Thx so mutsh..,
Gerrit _________________ ___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________ |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Tue Apr 05, 2005 1:35 pm Post subject: |
|
|
At any rate you got a wrong sequence here:
| Code: | | Parse "%%Year;%%Day;%%Month;%%Std;%%Min;%%Sec",%%TimeConv |
It should be:
| Code: | | Parse "%%Year;%%Month;%%Day;%%Std;%%Min;%%Sec",%%TimeConv |
Same goes for the UNIX function
Greetz
Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
gerrit Newbie

Joined: 14 May 2004 Posts: 24
|
Posted: Wed Apr 06, 2005 2:46 pm Post subject: |
|
|
... well after 3 Day's experementing with the DateTime stuff I get eaven more confused/frustrated. I have no clue what are the values VDS is calculating, and it's extremly hard to debug this kind of stuff. Is there somewhere a calculator for all these wired Time date formats? I'm shure that @Timedate() func's are working perfectly, but brain is to small to understand the the results.... ;( It's like "At 38446,6750578704 I go Shoppping
What I wanna do:
| Code: | | Have two dates and time from where I want to calculate the difference and displayed as "day's,Time". Then Calculate some Price Per hour or day |
The Way until now:
| Code: | Parsing %%DateOut and %%TimeOut into fragments
Parsing %%Date and %%Time into fragments
Convert both fragment strings into "whatever it is Unix/IndustryDate" with @timedate(ENCODEDT)
Calculating the Difference between %%DateOut%%TimeOut|%%Date%%Time with the @timedate(DiffVDS) Func
Convert result into @timedate(UNIX2DT) to convert it into a Human readable Value. |
The Code:
| Code: | %%TimeOut = 13-54-33
%%DateOut = 04-04-05
## = ?? %%DTOut= 38446,6750578704 ??
%%Time = 16-12-05
%%Date = 04-04-05
## = ?? %%DTIn= 38446,6749421296 ??
## = ?? Difference %%DTOut/%%DTIn 0,0001157408 ??
Parse "%%OutMonth;%%OutDay;%%OutYear",%%DateOut
Parse "%%OutStd;%%OutMin;%%OutSec",%%TimeOut
Parse "%%Month;%%Day;%%Year",%%Date
Parse "%%Std;%%Min;%%Sec",%%Time
%%dtOut = @timedate(ENCODEDT,20%%OutYear,%%OutMonth,%%OutDay,%%OutStd,%%OutMin,%%OutSec)
%%dtIn = @timedate(ENCODEDT,20%%Year,%%Month,%%Day,%%Std,%%Min,%%Sec)
%%TimeConv = @timedate(DiffVDS,%%dtIn,%%dtOut)
Parse "%%Year;%%Month;%%Day;%%Std;%%Min;%%Sec;%%Msec",%%TimeConv
%%TimeConv = @timedate(UNIX2DT,%%Year,%%Month,%%Day,%%Std,%%min,%%Sec,0) |
Results:
| Code: | ## Time Hour;Minute;Sec
## Date Day;Month;Year
## Expected Difference 00d.02h.14m.32s
## Expected Difference VDS 0,093425929364
## Result with Unix2DT is 25569
## Result with UNIX is nothing |
Thx for any Help..
Gerrit _________________ ___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________ |
|
| Back to top |
|
 |
Dr. Dread Professional Member


Joined: 03 Aug 2001 Posts: 1065 Location: Copenhagen, Denmark
|
Posted: Wed Apr 06, 2005 5:10 pm Post subject: |
|
|
VDS time values are not that difficult to understand: http://forum.vdsworld.com/viewtopic.php?t=919
******************
But you gotta remember to feed the PARSE command with the correct fieldsep:
| Code: |
option fieldsep,"-"
%%TimeOut = 13-54-33
%%DateOut = 04-04-05
%%Time = 16-12-05
%%Date = 04-04-05
Parse "%%OutMonth;%%OutDay;%%OutYear",%%DateOut
Parse "%%OutStd;%%OutMin;%%OutSec",%%TimeOut
Parse "%%Month;%%Day;%%Year",%%Date
Parse "%%Std;%%Min;%%Sec",%%Time
%%dtOut = @timedate(ENCODEDT,20%%OutYear,%%OutMonth,%%OutDay,%%OutStd,%%OutMin,%%OutSec)
%%dtIn = @timedate(ENCODEDT,20%%Year,%%Month,%%Day,%%Std,%%Min,%%Sec)
%%TimeConv = @timedate(DiffVDS,%%dtIn,%%dtOut)
option fieldsep,"|"
Parse "%%Year;%%Month;%%Day;%%Std;%%Min;%%Sec;%%Msec",%%TimeConv
info Elapsed Time:@cr()Days:%%Day@cr()Hours: %%Std@cr()Mins: %%Min@cr()Secs: %%Sec
|
Greetz
Dr. Dread _________________ ~~ Alcohol and calculus don't mix... Don't drink and derive! ~~
String.DLL * advanced string processing |
|
| Back to top |
|
 |
gerrit Newbie

Joined: 14 May 2004 Posts: 24
|
Posted: Wed Apr 06, 2005 11:24 pm Post subject: |
|
|
It's not a problem of a field seperation, i think..
If the Difference between
| Code: | 10-27-05 14:24:00 (1106832240) UNIX
10-27-05 14:25:00 (1106835900) UNIX |
is
| Code: | | 01.01.1970 01:01:00 (3660) UNIX = (25569,0423611111) UNIX2DT |
But with this Value I dont knew what to do with it. I'm not really intrested in the 1970's. I was expecting something like:
| Code: | | 00-00-0000 00:01:00 (3660) UNIX |
It seem's that the DT Format is only usable until
| Code: | | (25569) UNIX = (01.01.1970) | One less and the Function Unix2DT does'nt give me a value.
Well what ever, eaven when I Use now the DT Value of 25569,0423611111
I have 25569 Day's And 3660 Seconds Noooooo...
I read already a view Posts here, but none of them gave me the Fish..
... Gerrit
....sorry for the Spagetti Flood here.. but may it's helpful....
| Code: | #***************************** TimeCalc
If @Equal(@Dlgtext(Radio1),Time)
List Clear,Output
List Clear,Files1
List Clear,Files2
List Clear,dirs
List Filelist,Files1,%%PrjGlobalPath,D
%%Cnt = @Count(Files1)
%%N = 0
repeat
List Filelist,Files2,@Item(Files1,%%N)\Layers,D
%%N = @Succ(%%N)
Until @Equal(%%Cnt,%%N)
%%Cnt = @Count(Files2)
%%N = 0
List Clear,Files1
repeat
:OpenSyslog
List clear,Systemlog
List loadfile,Systemlog,@Item(Files2,%%N)\_MD\Systemlog._MD
%%Layer = @Name(@Item(Files2,%%N)).@Ext(@Item(Files2,%%N))
Directory change,@Item(Files2,%%N)\..\..
%%Scene = @Name(@CurDir())
## Abbruchsquenz für das ende des Logeintrags wenn NULL oder nicht vorhanden
%%Temp = @count(Systemlog)
Parse "%%Date;%%time;%%Temp03;%%Status;%%StatusUser;%%Flag",@Item(Systemlog,@sum(%%Temp,-1))
If @Equal(%%Flag,1)
List add,Output,%%Scene|%%Layer|0|Open Layer or Missing Log File
%%Switsh = 0
%%dtIn = ""
%%dtOut = ""
## Abbruch sequenz für Überlauf von %%N
If @greater(%%N,%%cnt)
else
%%N = @Succ(%%N)
Goto OpenSyslog
end
end
##____________________________________________
If @Equal(@Count(Systemlog),0)
%%SystemLogJump = 1
goto SystemLogJump
end
%%Cnt2 = @Count(Systemlog)
%%N2 = 0
repeat
:ZEROFlag
Parse "%%Date;%%time;%%Temp03;%%Status;%%StatusUser;%%Flag",@Item(Systemlog,%%N2)
If @Equal(%%Flag,1)
If @unequal(%%DTOut,"")
%%N2 = @Succ(%%N2)
goto ZEROFlag
end
Option fieldsep,-
Parse "%%Month;%%Day;%%Year",%%Date
%%OutMonth = %%Month
%%OutDay = %%Day
%%OutYear = %%Year
Option fieldsep,|
Option fieldsep,-
Parse "%%Std;%%Min;%%Sec",%%Time
%%OutStd = %%Std
%%OutMin = %%Min
%%OutSec = %%Sec
Option fieldsep,|
%%dtOut = @Timedate(UNIX,20%%OutYear,%%OutMonth,%%OutDay,%%OutStd,%%OutMin,%%OutSec)
If @unEqual(%%dtIn,"")
%%Switsh = 1
end
%%N2 = @Succ(%%N2)
elsif @Equal(%%Flag,0)
#*****
#If @greater(%%N2,@Count(Systemlog))
Parse "%%Date;%%time;%%Temp03;%%Status;%%StatusUser;%%Flag",@Item(Systemlog,@Sum(%%N2,1))
#end
If @Equal(%%Flag,0)
If @Greater(%%Cnt2,%%N2)
%%N2 = @Succ(%%N2)
Goto ZeroFlag
end
else
Parse "%%Date;%%time;%%Temp03;%%Status;%%StatusUser;%%Flag",@Item(Systemlog,@Sum(%%N2,0))
end
#*****
Option Fieldsep,-
Parse "%%Month;%%Day;%%Year",%%Date
Parse "%%Std;%%Min;%%Sec",%%Time
Option fieldsep,|
%%dtIn = @Timedate(UNIX,20%%Year,%%Month,%%Day,%%Std,%%Min,%%Sec)
Option fieldsep,|
If @unEqual(%%dtOut,"")
%%Switsh = 1
end
%%N2 = @Succ(%%N2)
end
## WriteSwitsh & BERECHNUNG
If @Equal(%%Switsh,1)
%%TimeConv = @DIFF(%%dtIn,%%dtOut)
#CLIPBOARD SET,%%OutStd:%%OutMin:%%Outsec@CR()%%Std:%%Min:%%sec@CR()"=A2-A1"
CLIPBOARD SET,@Timedate(Unix2DT,%%Timeconv)
#%%Timeconv = @Fdiv(@Fdiv(%%Timeconv,60),60)
List add,Output,%%Scene|%%Layer|%%TimeConv
%%Switsh = 0
%%dtIn = ""
%%dtOut = ""
end
#%%N2 = @Succ(%%N2)
Until @Greater(%%N2,%%Cnt2)
:SystemLogJump
%%SystemLogJump = 0
%%N = @Succ(%%N)
Until @greater(%%N,%%cnt)
end
Goto Evloop |
_________________ ___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________ |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Thu Apr 07, 2005 1:04 am Post subject: |
|
|
if i may suggest a solution that has worked well for me, i am writing the code off the top of my head and so hope that it is correct
| Code: |
%start_time = @datetime()
wait 5
%%finish_time = @datetime()
%%time_difference = @fsub(%%finish_time,%%start_time)
warn Time Difference @datetime(%%time_difference,dd days and hh:nn:ss)
|
this should return "0 days and 00:00:05" meaning 5 seconds
serge _________________
|
|
| Back to top |
|
 |
gerrit Newbie

Joined: 14 May 2004 Posts: 24
|
Posted: Sun Apr 10, 2005 3:34 pm Post subject: |
|
|
Yeepp that's it. Well the Difference Time is after convertionis something about 1890... But I helpt me out with the VDS Time, where the days are calculatable.. ie 12,23984...
After Twisting my brain around this Problem, I finaly realized that it my Datafile doesn't help me very mutsh.... ;(
But it's good, I leaned a lot about this experience...
Thanks again Serge,Dr. Dread  _________________ ___________________
Gerrit Corsmeyer
Gerrit@corsmeyer.de
www.corsmeyer.de
___________________ |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|