<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; VBScript: текущее время в формате с миллисекундами (hh:mm:ss.fff)]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=2810&amp;type=atom" />
	<updated>2009-02-28T11:10:37Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=2810</id>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: текущее время в формате с миллисекундами (hh:mm:ss.fff)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=20114#p20114" />
			<content type="html"><![CDATA[<p>Способ замера времени в коде с помощью объекта <a href="http://forum.script-coding.com/viewtopic.php?pid=20110#p20110">JSSys3.dll</a>:<br /></p><div class="codebox"><pre><code>Set oSys = CreateObject(&quot;JSSys3.Ops&quot;)
oSys.TimerStart()
WScript.Sleep 600
WScript.Echo oSys.TimerStop() &#039; количество прошедших миллисекунд</code></pre></div>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2009-02-28T11:10:37Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=20114#p20114</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: текущее время в формате с миллисекундами (hh:mm:ss.fff)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=20101#p20101" />
			<content type="html"><![CDATA[<p>Получение системной даты и времени с учетом настроек часового пояса с использованием библиотеки <a href="http://www.script-coding.com/dynwrapx.html">DynamicWrapperX</a>:</p><div class="codebox"><pre><code>&#039;-----------------------------------------------------------------------------
&#039;Получение системной даты и времени с учетом настроек часового пояса.
&#039;Потребуется зарегистрированная библиотека DynamicWrapperX
&#039;OC WinME/XP
&#039;-----------------------------------------------------------------------------
&#039;-----------------------------------------------------------------------------
Set DX=CreateObject(&quot;DynamicWrapperX&quot;)
&#039;-----------------------------------------------------------------------------
With DX
    .Register &quot;KERNEL32.DLL&quot;,&quot;GetLocalTime&quot;,&quot;i=l&quot;,&quot;r=l&quot;
    SYSTEMTIME=.StrPtr(String(16,Chr(32)))

    fRes=.GetLocalTime(SYSTEMTIME)

wYear        =.NumGet(SYSTEMTIME,0,&quot;t&quot;)    &#039;Год
wMonth        =.NumGet(SYSTEMTIME,2,&quot;t&quot;)    &#039;Месяц
wDayOfWeek    =.NumGet(SYSTEMTIME,4,&quot;t&quot;)    &#039;День недели
wDay        =.NumGet(SYSTEMTIME,6,&quot;t&quot;)    &#039;Число
wHour        =.NumGet(SYSTEMTIME,8,&quot;t&quot;)    &#039;Час
wMinute        =.NumGet(SYSTEMTIME,10,&quot;t&quot;)    &#039;Минута
wSecond    =.NumGet(SYSTEMTIME,12,&quot;t&quot;)    &#039;Секунда
wMilliseconds    =.NumGet(SYSTEMTIME,14,&quot;t&quot;)    &#039;Миллисекунда
End With
&#039;-----------------------------------------------------------------------------

If Len(wMinute)=1 Then wMinute=&quot;0&quot; &amp; wMinute
If Len(wSecond)=1 Then wSecond=&quot;0&quot; &amp; wSecond

MsgBox _
        &quot;~~~~~~~~~~~~~~~~~~~~~~~~~~~~&quot;    &amp; vbCR &amp; _
        vbTAB     &amp; &quot;Дата:&quot;                 &amp; vbCR &amp; _
        vbTAB    &amp; wDay                    &amp; vbCR &amp; _
        vbTAB     &amp; MonthName(wMonth)             &amp; vbCR &amp; _
        vbTAB     &amp; WeekDayName(wDayOfWeek,False,2)    &amp; vbCR &amp; _
        vbTAB     &amp; wYear                 &amp; vbCR &amp; _
        &quot;~~~~~~~~~~~~~~~~~~~~~~~~~~~~&quot;     &amp; vbCR &amp; _
        vbTAB     &amp; &quot;Время:&quot;                 &amp; vbCR &amp; _
        vbTAB     &amp; wHour    &amp; &quot;.&quot; &amp; _
            wMinute &amp; &quot;.&quot; &amp; _
            wSecond &amp; &quot;:&quot; &amp; _
            wMilliseconds                &amp; vbCR &amp; _
        &quot;~~~~~~~~~~~~~~~~~~~~~~~~~~~~&quot;     &amp; vbCR, _
        vbSystemModal+vbExclamation, _
        &quot;Текущие дата и время&quot;
&#039;-----------------------------------------------------------------------------
    Set DX=Nothing
    WScript.Quit()</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Poltergeyst]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=83</uri>
			</author>
			<updated>2009-02-28T07:06:06Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=20101#p20101</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: VBScript: текущее время в формате с миллисекундами (hh:mm:ss.fff)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=19811#p19811" />
			<content type="html"><![CDATA[<p>Ещё один способ получения текущего времени с миллисекундами:<br /></p><div class="codebox"><pre><code>Set timeNow = CreateObject(&quot;WScript.Shell&quot;).exec(&quot;CMD /C ECHO %TIME%&quot;).StdOut
msgbox timeNow.readline</code></pre></div><p>Автор идеи — <strong>kiber_punk</strong>.</p>]]></content>
			<author>
				<name><![CDATA[The gray Cardinal]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=2</uri>
			</author>
			<updated>2009-02-20T19:15:35Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=19811#p19811</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[VBScript: текущее время в формате с миллисекундами (hh:mm:ss.fff)]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=19748#p19748" />
			<content type="html"><![CDATA[<div class="codebox"><pre><code>Option Explicit

WScript.Echo &quot;Current time: &quot; &amp; strGetCurrTime(Timer)

WScript.Quit 0
&#039;=============================================================================

&#039;=============================================================================
Function strGetCurrTime(dtTimer)
    Dim intHours
    Dim intMinutes
    Dim intSeconds
    Dim intMilliSeconds
    
    intHours        = dtTimer \ (60 * 60)
    intMinutes      = (dtTimer - (intHours * (60 * 60))) \ 60
    intSeconds      = Fix(dtTimer - (intHours * (60 * 60)) - intMinutes * 60)
    intMilliSeconds = Fix((dtTimer - Fix(dtTimer)) * 1000)
    
    strGetCurrTime = CStr(TimeSerial(intHours, intMinutes, intSeconds)) &amp; &quot;.&quot; &amp; Right(&quot;000&quot; &amp; CStr(intMilliSeconds), 3)
End Function
&#039;=============================================================================</code></pre></div><p>Результат работы примера:<br /></p><div class="quotebox"><blockquote><p>Current time: 01:03:48.158</p></blockquote></div><p>При этом предполагаются следующие региональные настройки времени:<br /></p><div class="quotebox"><blockquote><p>REGEDIT4</p><p>[HKEY_CURRENT_USER\Control Panel\International]<br />&quot;sTime&quot;=&quot;:&quot;<br />&quot;sTimeFormat&quot;=&quot;HH:mm:ss&quot;<br />&quot;iTimePrefix&quot;=&quot;0&quot;</p></blockquote></div><p><strong><em>Замечание</em></strong>: функция VBScript «Timer», как и любой другой метод измерения времени, имеет определённую точность (или, что в данном случае более правильно, разрешающую способность) измерения. Оценить её среднюю величину для конкретной программно-аппаратной конфигурации можно с помощью следующего скрипта:<br /></p><div class="codebox"><pre><code>Option Explicit


Dim arrTimerValues(1024)
Dim StartTimerValue

Dim i
Dim Summ


StartTimerValue   = Timer
arrTimerValues(0) = Timer - StartTimerValue

Summ = 0

For i = LBound(arrTimerValues) + 1 To UBound(arrTimerValues)
    Do
        arrTimerValues(i) = Timer - StartTimerValue
    Loop Until arrTimerValues(i) &lt;&gt; arrTimerValues(i - 1)
    
    Summ = Summ + (arrTimerValues(i) - arrTimerValues(i - 1))
Next

&#039;WScript.Echo &quot;Time, sec     &quot; &amp; vbTab &amp; &quot;Diff, sec     &quot;
&#039;WScript.Echo &quot;==============&quot; &amp; vbTab &amp; &quot;==============&quot;
&#039;
&#039;For i = LBound(arrTimerValues) + 1 To UBound(arrTimerValues)
&#039;    WScript.Echo FormatNumber(arrTimerValues(i), 9) &amp; vbTab &amp; FormatNumber(arrTimerValues(i) - arrTimerValues(i - 1), 9)
&#039;Next

WScript.Echo &quot;==============&quot; &amp; vbTab &amp; &quot;==============&quot;
WScript.Echo &quot;Average, sec  &quot; &amp; vbTab &amp; FormatNumber(Summ / 1024, 9)
WScript.Echo &quot;==============&quot; &amp; vbTab &amp; &quot;==============&quot;

WScript.Quit 0</code></pre></div><p>Отдельное спасибо коллеге <strong>kefi</strong> за замечание.</p><p><strong><em>Дополнение</em></strong>: измерить характеристики таймера также можно с помощью утилиты <a href="http://technet.microsoft.com/en-us/sysinternals/bb897568.aspx">ClockRes</a>.</p>]]></content>
			<author>
				<name><![CDATA[alexii]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=1844</uri>
			</author>
			<updated>2009-02-19T22:10:44Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=19748#p19748</id>
		</entry>
</feed>
