Kogmedia Posted June 7, 2007 Posted June 7, 2007 (edited) Hello, I have found a little VB program for converting Unix time stamps, I would like to convert to AutoIt Would this be possible? I have very basic experience with VB There are few lines I would like to convert, Could I use dll calls? Dim span As New TimeSpan span = dateTime2.Value.ToUniversalTime() - dateTime Dim returnerItem As New Long returnerItem = span.TotalSeconds ;ToUniversalTime Converts the value of the current DateTime object to Coordinated Universal Time (UTC). Namespace: System Assembly: mscorlib (in mscorlib.dll) ;span.TotalSeconds Represents a time interval. Namespace: System Assembly: mscorlib (in mscorlib.dll) Thanks, Keith Edited June 7, 2007 by Kogmedia [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
poisonkiller Posted June 7, 2007 Posted June 7, 2007 Try, if that works: http://www.autoitscript.com/forum/index.ph...&hl=convert
Kogmedia Posted June 7, 2007 Author Posted June 7, 2007 I tried the VAConvert.04 it supports .vbs the file extension .vb I changed it but it didn't do anything? [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
ptrex Posted June 8, 2007 Posted June 8, 2007 @all This should be the translation Dim $span $span = $dateTime2.Value.ToUniversalTime() - $dateTime Dim $returnerItem $returnerItem = $span.TotalSeconds regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Kogmedia Posted June 8, 2007 Author Posted June 8, 2007 (edited) Hello, I have tryed the code you have posted but I get the error message; C:\Documents and Settings\Kog Media\Desktop\unixtime.au3 (12) : ==> Variable must be of type "Object".: $span = $UnixTime.Value.ToUniversalTime() - $dateTime $span = $UnixTime^ ERROR ;Original Program ;http://www.brianprice.ca/2007/06/02/a-lil-program-i-created/ #include <Date.au3> ; Calculated the number of seconds since EPOCH (1970/01/01 00:00:00) $dateTime = _DateDiff( 's',"1970/01/01 00:00:00",_NowCalc()) $UnixTime = '1180292400000' Dim $span $span = $UnixTime.Value.ToUniversalTime() - $dateTime Dim $returnerItem $returnerItem = $span.TotalSeconds Thanks Edited June 8, 2007 by Kogmedia [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
ptrex Posted June 8, 2007 Posted June 8, 2007 @kogmedia Of course you get this error Variable must be of type "Object".: Because you never declared the ActiveX object Look for "createobject" in the original code. I don"t see it in the code sample you posted. regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
Kogmedia Posted June 8, 2007 Author Posted June 8, 2007 @ptrex I can't see "createobject" in the original code. Sorry I have never used ObjCreate before Here is the full source code expandcollapse popupImports System.DateTime Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load dateTime2.Hide() End Sub Private Sub optionselect1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optionselect1.CheckedChanged Me.dateTime1.Show() Me.dateTime2.Hide() End Sub Private Sub optionselect2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optionselect2.CheckedChanged Me.dateTime2.Show() Me.dateTime1.Hide() End Sub Private Sub cnvrtButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cnvrtButton.Click If Me.optionselect1.Checked = True Then If Me.dateTime1.Text = Nothing Then MessageBox.Show("Please Enter A Unix Time Stamp", "Missing Parameter", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End If calcWindowsTime() ElseIf Me.optionselect2.Checked = True Then If Me.dateTime2.Text = Nothing Then MessageBox.Show("Please Enter A Unix Time Stamp", "Missing Parameter", MessageBoxButtons.OK, MessageBoxIcon.Error) Return End If calcUnixTime() End If End Sub Private Sub calcWindowsTime() ' This function will take the unix time, which is seconds from 01/01/1970 at 00:00:00 GMT, and convert to a String time Dim dateTime As New System.DateTime(1970, 1, 1, 0, 0, 0, 0) dateTime = dateTime.AddSeconds(Me.dateTime1.Text).ToLocalTime() Me.results.Text = dateTime.ToShortDateString & " " & dateTime.ToShortTimeString End Sub Private Sub calcUnixTime() Dim dateTime As New DateTime(1970, 1, 1, 0, 0, 0, 0) Dim stringDate = Me.dateTime2.Text Dim span As New TimeSpan span = dateTime2.Value.ToUniversalTime() - dateTime Dim returnerItem As New Long returnerItem = span.TotalSeconds Me.results.Text = returnerItem End Sub End Class [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
ptrex Posted June 8, 2007 Posted June 8, 2007 @Kogmedia These functions illustrated in the code are not exactly compatible with AU3 You will have to write your own function for this This might get you going expandcollapse popup$timer = TimerInit() While 1 $iTimerDiff = TimerDiff($timer) ToolTip(_TimeToString($iTimerDiff),0,0) sleep(250) WEnd Func _TimeToString($timestamp) Local $_time, $_h, $_m, $_s, $_message $_time = Round($timestamp / 1000, 0) $_h = Int($_time / 3600) $_m = Int(($_time - $_h * 3600) / 60) $_s = $_time - $_h * 3600 - $_m * 60 If ($_h > 0) Then $_message = StringFormat("%02d:%02d:%02d", $_h, $_m, $_s) ElseIf ($_m > 0) Then $_message = StringFormat("%02d:%02d", $_m, $_s) ElseIf ($_s > 0) Then $_message = StringFormat("%02d", $_s) Else $_message = "" EndIf Return $_message EndFuncoÝ÷ Ù©Ýjëh×6Local $Time1 = '00:622:09', $Time2 = '02:1788:05' MsgBox(0, 'Subtract / Add', 'Subtracted: ' & _StrAddSub($Time1, $Time2, 0) & @CR & _ 'Added: ' & _StrAddSub($Time1, $Time2)) Func _StrAddSub($sTime1, $sTime2, $iAdd = 1, $sDelim = ':'); $iAdd = 1 Add, $iAdd = 0 Subtract Local $aSplit1 = StringSplit($sTime1, $sDelim), $iSubTotal = 0 Local $aSplit2 = StringSplit($sTime2, $sDelim) If $aSplit1[0] <> 3 Or $aSplit2[0] <> 3 Then Return SetError(0, 0, 0) Local $iTotal1 = ((Int($aSplit1[1]) * 3600) + (Int($aSplit1[2]) * 60) + (Int($aSplit1[3]))) Local $iTotal2 = ((Int($aSplit2[1]) * 3600) + (Int($aSplit2[2]) * 60) + (Int($aSplit2[3]))) If $iAdd Then $iSubTotal = $iTotal1 + $iTotal2 ElseIf $iTotal1 >= $iTotal2 Then $iSubTotal = $iTotal1 - $iTotal2 Else $iSubTotal = $iTotal2 - $iTotal1 EndIf Local $iHour = Int(($iSubTotal / 3600)) Local $iMin = Int(($iSubTotal - ($iHour * 3600)) / 60) Local $iSec = Int(($iSubTotal - $iHour * 3600) - ($iMin * 60)) Return StringFormat('%02d', $iHour) & $sDelim & StringFormat('%02d', $iMin) & $sDelim & StringFormat('%02d', $iSec) EndFunc Hope this helps regards ptrex Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
randallc Posted June 9, 2007 Posted June 9, 2007 Hi,Not sure if it is your issue, but @arcker did some conversions with Unix time stamp, and we made a vbs script to run in AutoIt;VBconvert + dateIf you give me an example of the input data you have , I could have a look. And I think, even better, @arcker understands it!Best, randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
Kogmedia Posted June 13, 2007 Author Posted June 13, 2007 Hi,Not sure if it is your issue, but @arcker did some conversions with Unix time stamp, and we made a vbs script to run in AutoIt;VBconvert + dateIf you give me an example of the input data you have , I could have a look. And I think, even better, @arcker understands it!Best, randallHere is an example date Unix: 1180292400000Real Date: 27/05/2007 20:00Thanks It would be great to get unix time in autoit [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
Mast3rpyr0 Posted June 13, 2007 Posted June 13, 2007 y do u need to convert unix TS with a windows language? My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here!
Kogmedia Posted June 13, 2007 Author Posted June 13, 2007 y do u need to convert unix TS with a windows language?Because eBay gives time in Unix and 1180292400000 doesn't make a lot of sense to me [font="Verdana"]Keith (Kogmedia)[/font]My ScriptQuick Search - Internet / Hard Drive Search
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now