473,748 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

time zone/daylight savings time help needed

Hey all.

I know with Perl "there's more than one way to do it", but I'd rather
not reinvent the wheel...

/usr/share/zoneinfo/Etc/
contains files like GMT-5 or GMT+8 etc which would be really handy for
me to tweak $ENV{'TZ'} to play with dates and times, but I'm trying to
find the 'best' approach to handle this scenario:

- user adds a meeting time in local time (Pacific time) which is
stored in MySQL
- when another user logs in, they see the time converted to their own
TZ offset, which is configured based on their country
(in the case where their country has multiple TZ's, they are asked
what time it is at their location to help my script determine their
offset relative to UTC)

I have Date::Manip at my disposal, but not sure of the 'best' approach
for handling this work, or if that library is even best suited for
this.

FYI: Server's timezone is set to UTC... figured it was easiest that
way?

My thoughts are this:
- use Date::Manip to see if the current date/time is between 2am on
the first Sunday of April or 2am on the last Sunday of October (1986's
mandated rules for US daylight savings time)
- meeting time/day-of-week is manipulated using Date::Manip's
&ParseDate() subroutine with "+ 7 hours" or "+ 8 hours", accordingly,
and stored in the database (MySQL as DATETIME field type)
- when another user logs in, I know their offset relative to UTC, but
have no 'rules' for determining whether they too are affected by DST
or not, as these users will be world-wide... and that's my roadblock -
if they are affected by DST as well, I need another way to convert the
time/date of the meeting accordingly.

/usr/share/zoneinfo/ may not be useful considering our end users may
not know which zone file to pick from a list if (for example) I just
list all of the files within the /Asia/ folder, and they live in
Moscow, since Moscow is not listed in the /Asia/ folder. (it's listed
in /Europe/ but last time I checked a map, Russia was part of Asia)

So I'm stuck with a user-friendly way of showing my users what time a
meeting is at in their local time since I'm not confident of how best
to determine whether DST affects their TZ offset from GMT.

The other drawback with /usr/share/zoneinfo/Etc/ is that there are no
"half hour" files, such as Newfoundland time in Canada, which is an
extra half hour ahead of Atlantic time.

Any feedback, insight, perldoc references, or example code would be
most welcomed.

-g*****@w98.us
Jul 19 '05 #1
1 7311
go****@w98.us (ian douglas) wrote in message news:<b6******* *************** ****@posting.go ogle.com>...
Hey all.

I know with Perl "there's more than one way to do it", but I'd rather
not reinvent the wheel...

/usr/share/zoneinfo/Etc/
contains files like GMT-5 or GMT+8 etc which would be really handy for
me to tweak $ENV{'TZ'} to play with dates and times, but I'm trying to
find the 'best' approach to handle this scenario:
Time::Local::ti melocal() and localtime() should honour $ENV{TZ}.
However on some OSs (or rather LIBCs) they don't honour changes in
$ENV{TZ} after the first call.
/usr/share/zoneinfo/ may not be useful considering our end users may
not know which zone file to pick from a list if (for example) I just
list all of the files within the /Asia/ folder, and they live in
Moscow, since Moscow is not listed in the /Asia/ folder. (it's listed
in /Europe/ but last time I checked a map, Russia was part of Asia)


Report bugs to your /usr/share/zoneinfo/ to your OS vendor.

This newsgroup does not exist (see FAQ). Please do not start threads
here.
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3667
by: Bathroom_Monkey | last post by:
For posterity's sake, here is an algorithm I created to take a GMT time and convert it to U.S. central time, accounting for daylight saving time. Note: this algorithm can be modified to work for any other U.S. timezone by changing the number of second subtracted at the end. <? $in_dst="false";
8
9260
by: Monty | last post by:
Let's say you provide an online service from 7:00AM to 6:00PM Eastern Time (daylight time in the summer). Is there way of showing these hours of availability on a web page in the user's local time? Thanks in advance for any advice.
10
5264
by: Marc Pelletier | last post by:
Hello, I am writing an application that does some simple astronomical calculations. One of the variables I need is the number of hours passed in this year. I've written the following function public static double GetHoursofYear( DateTime aTime ) { DateTime StartYear = new DateTime( aTime.Year, 1, 1 ); return ( aTime.ToOADate() - StartYear.ToOADate() ) * 24;
1
30150
by: Drew | last post by:
Is there a way to check if it is daylight savings or not via c#? I have heard you can use System.Globalization? Thanks - Drew
5
5797
by: ECVerify.com | last post by:
I am trying to convert a computers local time to Pacific time, I can get it back to UTC pretty easy but I actually want to convert whatever the local time is on the computer I want to calculate what it would currently be in Pacific time. Taking in account Daylight Savings Time Thanks, Ed,
2
2199
by: Joshua J. Kugler | last post by:
I've read docs (datetime, time, pytz, mx.DateTime), googled, and experimented. I still don't know how to accomplish what I want to accomplish. I'm loading up a bunch of date/time data that I then need to do math on to compare it to the current date/time. I can get the current time easily enough: currentTime = datetime.datetime.now(pytz.timezone('America/Anchorage'))
6
5157
by: dredge | last post by:
Hi, the server that hosts my PHP pages has its clock set to Greenwich Mean Time (GMT timezone 0). I need for my PHP scripts to have access to my local time which is Central Standard Time in the U.S. (CST timezone -6). Note: daylight savings time _is_ observed in my state. I have looked all over a PHP algorithm that would convert GMT to CST but have so far not been successful. Does anyone have such an algorithm lying around that they could...
4
4404
by: Polaris431 | last post by:
I have a web application in ASP.NET that will be used globally. Data is collected on mobile devices running Windows Mobile and sent to the web server where it is stored and can be viewed. Data is timestamped when it is sent from a PDA device to the server. I am writing software for both the web app and the PDA. The web server is located at one location while the PDA devices are located around the world. The question is, how do I handle...
1
8052
by: gnupun | last post by:
Hi, I'm trying to compute current time for mountain standard time with daylight savings (MDT);and without DST (MST), eg: Phoenix, AZ. If I use the PHP timezone "US/Mountain", it returns MDT correctly. What is the PHP time zone for MST? Similarly, are there PHP time zones for Pacific, Central and Eastern time zones without Daylight Savings? The PHP time zones US/Pacific, US/
0
9555
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9250
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8247
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6076
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4878
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.