473,405 Members | 2,261 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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 7293
go****@w98.us (ian douglas) wrote in message news:<b6**************************@posting.google. 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::timelocal() 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
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...
8
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...
10
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 ...
1
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
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...
2
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...
6
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...
4
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.