A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Handle different international time zones for Item.Start and Item.



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 4th 08, 01:16 PM posted to microsoft.public.outlook.program_vba
masani paresh[_2_]
external usenet poster
 
Posts: 84
Default Handle different international time zones for Item.Start and Item.

Hi Friends,

My mail goal is to get the UTC time for local zone. I am facing problems in
handling internation time zones in VBScript for Item.Start and Item.End.
Could any one tell me in brief/code to handle different international time
zones. I thought of the below solution:

1. Get the UTC time
2. Get the time difference with local zone
3. Add it to UTC.

Is there any ways to do this in VBScript?

Thanks in Advance,
Megha

  #2  
Old August 4th 08, 02:10 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Handle different international time zones for Item.Start and Item.

You'd need to use WSH (Windows Scripting) to read the registry to get those
settings.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
Hi Friends,

My mail goal is to get the UTC time for local zone. I am facing problems
in
handling internation time zones in VBScript for Item.Start and Item.End.
Could any one tell me in brief/code to handle different international time
zones. I thought of the below solution:

1. Get the UTC time
2. Get the time difference with local zone
3. Add it to UTC.

Is there any ways to do this in VBScript?

Thanks in Advance,
Megha


  #3  
Old August 4th 08, 02:28 PM posted to microsoft.public.outlook.program_vba
masani paresh[_2_]
external usenet poster
 
Posts: 84
Default Handle different international time zones for Item.Start and I

We can do it in VB like below:

Dim testTime As DateTime = DateTime.Now
Debug.WriteLine(testTime.ToString)
Debug.WriteLine(testTime.ToUniversalTime.ToString)

Is there any function in VBScript that can convert local time to UTC?

Thanks,
Paresh

"Ken Slovak - [MVP - Outlook]" wrote:

You'd need to use WSH (Windows Scripting) to read the registry to get those
settings.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
Hi Friends,

My mail goal is to get the UTC time for local zone. I am facing problems
in
handling internation time zones in VBScript for Item.Start and Item.End.
Could any one tell me in brief/code to handle different international time
zones. I thought of the below solution:

1. Get the UTC time
2. Get the time difference with local zone
3. Add it to UTC.

Is there any ways to do this in VBScript?

Thanks in Advance,
Megha



  #4  
Old August 4th 08, 03:46 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Handle different international time zones for Item.Start and I

That's using VB.NET.

There are no equivalents in VBScript or Windows scripting for
ToUniveralTime().

You'd have to write your own function for that. Or you could search on the
Web to see if anything like that has been done using VBScript or possibly
VBA or VB6. If you found code in VB6 or VBA you'd need to translate it into
VBScript code.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
We can do it in VB like below:

Dim testTime As DateTime = DateTime.Now
Debug.WriteLine(testTime.ToString)
Debug.WriteLine(testTime.ToUniversalTime.ToString)

Is there any function in VBScript that can convert local time to UTC?

Thanks,
Paresh


  #5  
Old August 4th 08, 05:01 PM posted to microsoft.public.outlook.program_vba
masani paresh[_2_]
external usenet poster
 
Posts: 84
Default Handle different international time zones for Item.Start and I

Thanks Ken, I have done it in following way.

sTime = Format(Item.Start,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset)
eTime = Format(Item.End,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" & timeOffset)

I have hard coded time offsets for different time zone that is required. I
am getting local site and corresponding time zone offset and adding it to
current time to get the UTC.

Could you see any improvement that i can make here.

Thanks,
Paresh

"Ken Slovak - [MVP - Outlook]" wrote:

That's using VB.NET.

There are no equivalents in VBScript or Windows scripting for
ToUniveralTime().

You'd have to write your own function for that. Or you could search on the
Web to see if anything like that has been done using VBScript or possibly
VBA or VB6. If you found code in VB6 or VBA you'd need to translate it into
VBScript code.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
We can do it in VB like below:

Dim testTime As DateTime = DateTime.Now
Debug.WriteLine(testTime.ToString)
Debug.WriteLine(testTime.ToUniversalTime.ToString)

Is there any function in VBScript that can convert local time to UTC?

Thanks,
Paresh



  #6  
Old August 4th 08, 05:46 PM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Handle different international time zones for Item.Start and I

Keep in mind that the offsets will be different depending on whether
Daylight Savings Time (DST) is observed and whether the given date falls
with the DST.
Keep in mind that on the MAPI level, these propertiss are already stored in
UTC, so you can simply access teh raw MAPI properties using Extended MAPI,
CDO 1.21, or Redemption.
plug Redemption (url below) exposes time zones through the
RDOSession.Timeszones collection -
http://www.dimastr.com/redemption/rdo/rdotimezones.htm /plug

--
Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
-
"masani paresh" wrote in message
...
Thanks Ken, I have done it in following way.

sTime = Format(Item.Start,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" &
timeOffset)
eTime = Format(Item.End,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" &
timeOffset)

I have hard coded time offsets for different time zone that is required. I
am getting local site and corresponding time zone offset and adding it to
current time to get the UTC.

Could you see any improvement that i can make here.

Thanks,
Paresh

"Ken Slovak - [MVP - Outlook]" wrote:

That's using VB.NET.

There are no equivalents in VBScript or Windows scripting for
ToUniveralTime().

You'd have to write your own function for that. Or you could search on
the
Web to see if anything like that has been done using VBScript or possibly
VBA or VB6. If you found code in VB6 or VBA you'd need to translate it
into
VBScript code.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
We can do it in VB like below:

Dim testTime As DateTime = DateTime.Now
Debug.WriteLine(testTime.ToString)
Debug.WriteLine(testTime.ToUniversalTime.ToString)

Is there any function in VBScript that can convert local time to UTC?

Thanks,
Paresh





  #7  
Old August 4th 08, 06:41 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Handle different international time zones for Item.Start and I

I'd agree with Dmitry that you aren't handling DST dates and hard coding
offsets is not a good way to go.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
Thanks Ken, I have done it in following way.

sTime = Format(Item.Start,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" &
timeOffset)
eTime = Format(Item.End,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "+" &
timeOffset)

I have hard coded time offsets for different time zone that is required. I
am getting local site and corresponding time zone offset and adding it to
current time to get the UTC.

Could you see any improvement that i can make here.

Thanks,
Paresh


  #8  
Old August 5th 08, 08:22 AM posted to microsoft.public.outlook.program_vba
masani paresh[_2_]
external usenet poster
 
Posts: 84
Default Handle different international time zones for Item.Start and I

Hi Ken,
I have written following steps to get the UTC value of current time by
reading reg keys. But when it executes the set oShell =
CreateObject("WScript.Shell") statement, it show the dialog box for
confirming some installation. I have to click yes then it will proceed and
works fine. Could you tell me how to make this statement to work silently.

startTime = Item.Start
endTime = Item.End
set oShell = CreateObject("WScript.Shell")
atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" &_
"Control\TimeZoneInformation\ActiveTimeBias"
offsetMin = oShell.RegRead(atb)
startTime = dateadd("n", offsetMin, startTime)
endTime = dateadd("n", offsetMin, endTime)

startTime = Format(startTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z")
endTime = Format(endTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z")
MsgBox startTime & vbcrlf & endTime

Thanks,
Paresh

"Ken Slovak - [MVP - Outlook]" wrote:

You'd need to use WSH (Windows Scripting) to read the registry to get those
settings.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
Hi Friends,

My mail goal is to get the UTC time for local zone. I am facing problems
in
handling internation time zones in VBScript for Item.Start and Item.End.
Could any one tell me in brief/code to handle different international time
zones. I thought of the below solution:

1. Get the UTC time
2. Get the time difference with local zone
3. Add it to UTC.

Is there any ways to do this in VBScript?

Thanks in Advance,
Megha



  #9  
Old August 5th 08, 02:30 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Handle different international time zones for Item.Start and I

It shouldn't if WSH is installed already. I never get that prompt when
instantiating a WSH object.

What happens if you try that line from a simple VBS file you can create
using Notepad? Do you always get the same prompt:

Set oShell = CreateObject("WScript.Shell")

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
Hi Ken,
I have written following steps to get the UTC value of current time by
reading reg keys. But when it executes the set oShell =
CreateObject("WScript.Shell") statement, it show the dialog box for
confirming some installation. I have to click yes then it will proceed and
works fine. Could you tell me how to make this statement to work silently.

startTime = Item.Start
endTime = Item.End
set oShell = CreateObject("WScript.Shell")
atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" &_
"Control\TimeZoneInformation\ActiveTimeBias"
offsetMin = oShell.RegRead(atb)
startTime = dateadd("n", offsetMin, startTime)
endTime = dateadd("n", offsetMin, endTime)

startTime = Format(startTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z")
endTime = Format(endTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z")
MsgBox startTime & vbcrlf & endTime

Thanks,
Paresh


  #10  
Old August 5th 08, 03:33 PM posted to microsoft.public.outlook.program_vba
masani paresh[_2_]
external usenet poster
 
Posts: 84
Default Handle different international time zones for Item.Start and I

Do you always get the same prompt:
Not always. I got it first time when I ran the customized outlook form. And
I also got it when I ran it after restarting my machine.

Thanks,
Paresh

"Ken Slovak - [MVP - Outlook]" wrote:

It shouldn't if WSH is installed already. I never get that prompt when
instantiating a WSH object.

What happens if you try that line from a simple VBS file you can create
using Notepad? Do you always get the same prompt:

Set oShell = CreateObject("WScript.Shell")

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"masani paresh" wrote in message
...
Hi Ken,
I have written following steps to get the UTC value of current time by
reading reg keys. But when it executes the set oShell =
CreateObject("WScript.Shell") statement, it show the dialog box for
confirming some installation. I have to click yes then it will proceed and
works fine. Could you tell me how to make this statement to work silently.

startTime = Item.Start
endTime = Item.End
set oShell = CreateObject("WScript.Shell")
atb = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\" &_
"Control\TimeZoneInformation\ActiveTimeBias"
offsetMin = oShell.RegRead(atb)
startTime = dateadd("n", offsetMin, startTime)
endTime = dateadd("n", offsetMin, endTime)

startTime = Format(startTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z")
endTime = Format(endTime,"yyyy-mm-dd" & "T" & "hh:mm:ss" & "Z")
MsgBox startTime & vbcrlf & endTime

Thanks,
Paresh


Do you always get the same prompt:

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how do I automatically display start time in calendar item Ed B. Outlook - Calandaring 0 March 28th 08 12:40 PM
Item.Save and Item.Close Script causes Outlook 2007 to Crash Rayyan Outlook - Using Forms 6 November 25th 06 03:14 AM
Saving exception item in recurring appointment item fails Dikbill Outlook and VBA 2 July 11th 06 03:59 PM
How do I display item start times? JessChamp Outlook - Calandaring 0 May 2nd 06 11:16 PM
How can I set a calender appointment start and end time zones teebaldwin Outlook - Calandaring 3 March 30th 06 05:28 PM


All times are GMT +1. The time now is 11:32 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.