Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#23852 closed Bug (invalid)

Timezone works inconsistently under Cygwin and Windows

Reported by: wlnirvana Owned by: nobody
Component: Core (Management commands) Version: 1.6
Severity: Normal Keywords: timezone
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by wlnirvana)

Environment: Win 7 (64-bit) + Cygwin (64-bit) + Django 1.6.5
Current time in Windows system: 2014-11-17 16:25 HKT

If I create a project and run it under Cygwin, I get the following

$ django-admin.py startproject foobar
$ cd foobar/
$ python manage.py runserver
Validating models...

0 errors found
November 17, 2014 - 08:26:10
Django version 1.6.5, using settings 'foobar.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

Note the time is around 8:30 in the morning!!!

And if I switch to Windows and run the exact same project I just created, I get:

D:\cygwin64\home\Administrator\foobar>python manage.py runserver
Validating models...

0 errors found
November 17, 2014 - 16:29:10
Django version 1.6.5, using settings 'foobar.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.

This time it correctly shows the local time.

EDIT:
Here is an excerpt of settings.py generated by django-admin.py startproject foobar command.

 TIME_ZONE = 'UTC'

 USE_I18N = True

 USE_L10N = True

 USE_TZ = True

Change History (5)

comment:1 by wlnirvana, 9 years ago

Description: modified (diff)

comment:2 by Aymeric Augustin, 9 years ago

What's the value of your TIME_ZONE setting? What's your system time zone?

See also https://docs.djangoproject.com/en/1.7/ref/settings/#time-zone and the caveat about Windows.

in reply to:  2 comment:3 by wlnirvana, 9 years ago

Replying to aaugustin:

What's the value of your TIME_ZONE setting? What's your system time zone?

See also https://docs.djangoproject.com/en/1.7/ref/settings/#time-zone and the caveat about Windows.

See edit above. TIME_ZONE is set to'UTC' automatically by the startproject command. I didn't do any modification to settings.py once it was generated.

Last edited 9 years ago by wlnirvana (previous) (diff)

comment:4 by Aymeric Augustin, 9 years ago

Resolution: invalid
Status: newclosed

As explained in the documentation, you must set TIME_ZONE to the name of the HKT time zone in the tz database. Windows doesn't support doing things in a time zone that isn't the system time zone.

Cygwin appears not to suffer from this limitation and manages to run your project in UTC as required by your settings file.

in reply to:  4 comment:5 by wlnirvana, 9 years ago

Replying to aaugustin:

As explained in the documentation, you must set TIME_ZONE to the name of the HKT time zone in the tz database. Windows doesn't support doing things in a time zone that isn't the system time zone.

Cygwin appears not to suffer from this limitation and manages to run your project in UTC as required by your settings file.

I got it. I mistook the note as you must explicitly set TIME_ZONE in windows. Thanks a lot.

Note: See TracTickets for help on using tickets.
Back to Top