Dates, Times, and Time Zones

From WeBWorK_wiki
Jump to navigation Jump to search

General Information

WeBWorK uses the Olson database (http://en.wikipedia.org/wiki/Zoneinfo) for time zone information. To see a list of valid time zones connect to http://search.cpan.org/dist/DateTime-TimeZone/

These time zones are more refined than standard time zone usage in that they include switches to daylight savings time (e.g. some parts of a time zone may make the switch and others may not). For example if you are in the eastern US, on the list you will see DateTime::TimeZone::America::New_York and you should use America/New_York when entering time zone information into WeBWorK.

A default time zone for the WeBWorK system is set in the file /opt/webwork/webwork2/conf/global.conf In that file, e.g. replace $siteDefaults{timezone} = ""; by $siteDefaults{timezone} = "America/New_York";

To set a different time zone for a particular course, go to Course Configuration and enter your desired time zone under the General tag.

There is a subtle difference in how date/times are entered into WeBWorK and how they are displayed but almost no one will notice this difference. In the Hmwk Sets Editor you will see date/times displayed as 11/14/2009 at 07:45am EST. You can always enter date/times in the format 11/14/2009 at 07:45am without the time zone information and WeBWorK will use the same time zone the course uses. You can usually enter dates/times in the format WeBWorK uses to display them, e.g. 11/14/2009 at 07:45am EST with the time zone information. However, for a few places in the world, this will cause an error.

Possible Errors

As we said above you can usually enter date/times in the format WeBWorK uses to display them, e.g. 11/14/2009 at 07:45am EST with the time zone information. But not always. For example if you are in Israel, you would use Asia/Jerusalem as your time zone and WeBWorK will display date/times in the format 10/24/2012 at 08:17am IST. However if you enter a date/time in this format, you will get the error message

Error messages
   Time zone 'IDT' not recognized.

Entering the date/time in the format 10/24/2012 at 08:17am works fine and is usually what you want to do. WeBWorK uses whatever time zone the course is set up to use so in this case WeBWorK displays 10/24/2012 at 08:17am IST. You can also use the format 10/24/2012 at 08:17am Asia/Jerusalem which gives the same result. You can use other time zones, e.g. 10/24/2012 at 08:17am America/New_York but in this case WeBWorK displays 10/24/2012 at 02:17pm IST.

If you are interested in what is really going on, continue reading.

Detailed Information

The main module is

http://search.cpan.org/~drolsky/DateTime-TimeZone-1.01/lib/DateTime/TimeZone.pm

This uses things like "Asia/Jerusalem" but also has short names such as IDT. Here's what is said about these short names:

   $tz->short_name_for_datetime( $dt )
   Given a DateTime object, this method returns the "short name" for the current observance and rule this datetime is in. These are names like "EST", "GMT", etc.
   It is strongly recommended that you do not rely on these names for anything other than display. These names are not official, and many of them are simply the invention of the Olson database maintainers. Moreover, these names are not unique. For example, there is an "EST" at both -0500 and +1000/+1100.


So these names are for display only. If instead of "IDT" you used "Asia/Jerusalem" there would be no error. But since the display uses e.g. EST, if someone entered EST the first part of the routine fails since EST (and IDT) are not valid. But since everyone probably does this (instead of using America/New_York) they just copy what the display looks like), we call a second module http://search.cpan.org/~gbarr/TimeDate-1.19/lib/Time/Zone.pm which knows quite a few short names - click on the above link and view the source to see them --- (but certainly not all). E.g. it does not know IDT or IST this is the reason for your error.

The best thing to do (as you have discovered) is to enter times without using IST or IDT and then dates/times will be in whatever timezone the course uses. I guess we could drop the time zone short name from the display but for most of the world, there is no problem. And if there is a problem, there is an easy solution so I think we will just leave things as they are.

If you want you can ask the authors of Zone.pm to update it adding ISD and IDT.