Django

Code

Ticket #1061 (new)

Opened 3 years ago

Last modified 3 months ago

Start week day on calendar

Reported by: antoni.aloy@gmail.com Assigned to: garcia_marc
Milestone: post-1.0 Component: Internationalization
Version: SVN Keywords: i18n admin i18n-rf
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description (Last modified by gwilson)

I thinks this is an issue of internationalization. The calendar widget starts the week on Sunday but in some countries (Spain for example) the week starts on Monday. On the other hand I haven't seen any way to change the date display format on the admin application, it displays 2005-12-14 instead of 14-12-2005 or 14/12/2005 which would be the default locale for Spain.

Attachments

calendar.diff (4.2 kB) - added by jezdez on 11/30/07 22:48:42.
Implemented WEEK_START_DAY and a little change to the calendar javascript code
calendar2.diff (5.0 kB) - added by jezdez on 12/01/07 08:24:22.
Refactored patch for use with DateField?, DateTimeField? and TimeField?, please patch a fresh checkout
1061.diff (1.6 kB) - added by garcia_marc on 06/28/08 18:12:17.
Fix and example of how djangojs.po files should be updated to work on every language

Change History

01/03/06 18:13:37 changed by anonymous

  • type changed from enhancement to defect.
  • severity changed from normal to major.
  • milestone set to Version 0.92.

01/04/06 01:39:04 changed by hugo

  • severity changed from major to normal.
  • milestone deleted.

This is more a problem of localization than internationalization, but could be fixed easily by adding a WEEK_STARTS_MONDAY switch to the config and to use that in the calendar code (by passing it from the view function to the javascript that draws the calendar).

04/23/06 17:53:59 changed by adrian

  • priority changed from normal to lowest.
  • severity changed from normal to minor.

06/02/06 06:23:17 changed by asmodai@in-nomine.org

I can name already three countries where the first day of the week is: Saturday, Sunday, and Monday. So that WEEK_STARTS_MONDAY switch needs to be a bit more configurable than that.

01/20/07 16:23:14 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Design decision needed.

08/25/07 19:49:27 changed by f

  • status changed from new to closed.
  • needs_better_patch set to 1.
  • component changed from Admin interface to HTTP handling.
  • keywords set to SUNDAY.
  • needs_docs set to 1.
  • resolution set to fixed.
  • stage changed from Design decision needed to Accepted.

08/25/07 20:09:04 changed by gwilson

  • status changed from closed to reopened.
  • description changed.
  • needs_better_patch deleted.
  • component changed from HTTP handling to Admin interface.
  • keywords deleted.
  • needs_docs deleted.
  • resolution deleted.

reverting spam.

09/14/07 17:12:11 changed by toke

What about: WEEK_START_DAY = 0-6 ? Monday == 0 ... Sunday == 6 as in datetime?

09/14/07 18:14:26 changed by antoni.aloy@gmail.com

It's a matter of convention, so getting the datetime one is as good as any other one.

10/01/07 14:11:42 changed by anonymous

It's more complicated than that, there are regional settings usually that let users select from a week numbering scheme (first full week after start of month = first week, first week that crosses nye = first week, week starts on monday, week starts on sunday) http://en.wikipedia.org/wiki/Week#Week_number http://en.wikipedia.org/wiki/ISO_week_date

I used to have a better link but can't seem to find it atm

11/30/07 18:10:44 changed by jezdez

  • owner changed from nobody to jezdez.
  • status changed from reopened to new.

11/30/07 22:48:42 changed by jezdez

  • attachment calendar.diff added.

Implemented WEEK_START_DAY and a little change to the calendar javascript code

12/01/07 05:28:01 changed by jezdez

  • has_patch set to 1.

12/01/07 06:23:10 changed by aaloy

I have applied the patch but it does not work for me, it simply makes calendar not appear anymore :(

12/01/07 06:43:19 changed by jezdez

Hm, sorry to hear that, did you restart your django process?

12/01/07 07:29:35 changed by aaloy

The patch works for DateTimeFields? but no for DateFields?.

12/01/07 08:24:22 changed by jezdez

  • attachment calendar2.diff added.

Refactored patch for use with DateField?, DateTimeField? and TimeField?, please patch a fresh checkout

12/01/07 08:37:40 changed by aaloy

Tested! It works on both DateField and DateTimeField

12/01/07 10:53:02 changed by jezdez

  • keywords set to sprintdec01.

06/26/08 12:37:46 changed by garcia_marc

  • keywords changed from sprintdec01 to i18n admin.
  • needs_better_patch set to 1.
  • component changed from Admin interface to Internationalization.
  • owner changed from jezdez to garcia_marc.
  • milestone set to 1.0 beta.

I think that the patch is too much complicated to achieve it (and probably commiters agree, so it hasn't been commited for several months).

I'll develop a better patch, and try to have this feature on 1.0.

I know that this is not explicitly in Jacob's maybe list, but I thing that if a good patch exists when 1.0 beta, it should be included, so tagging it as 1.0 beta.

(follow-up: ↓ 20 ) 06/26/08 12:42:04 changed by jezdez

Ehm, why do you think my patch is complicated?

(in reply to: ↑ 19 ) 06/26/08 18:21:15 changed by garcia_marc

Replying to jezdez:

Ehm, why do you think my patch is complicated?

I think that your patch can be improved easily, and following more "django standards". It's a good job, because you pointed out where the problem is, and how to fix this situation, but I think that a better patch is necessary.

I explained more clearly how my patch will be in the next thread: http://groups.google.com/group/django-developers/browse_thread/thread/db149543262b5b21/c51f020880badf41#c51f020880badf41

Don't take it personally, for sure you'll be able to improve my patch as well... :)

06/27/08 09:34:10 changed by garcia_marc

  • keywords changed from i18n admin to i18n admin i18n-rf.

06/28/08 18:12:17 changed by garcia_marc

  • attachment 1061.diff added.

Fix and example of how djangojs.po files should be updated to work on every language

06/28/08 18:19:09 changed by garcia_marc

  • needs_better_patch deleted.
  • stage changed from Accepted to Ready for checkin.

New patch fixes this issue using standard django's way to specify date formats... that is creating settings as strings on code, and marking them for gettext translation.

If the patch is commited, the djangojs.po file should be excluded. I've attached it just for showing how the patch will work.

The behaviour of admin calendar based on this patch, will be to set first day of week based on current language. If no setting is found, then it will be used default application language setting, then english setting, and finally Sunday.

06/28/08 18:45:53 changed by jezdez

Great! That patch is much more elegant!

07/03/08 08:37:07 changed by gwilson

  • milestone deleted.

An enhancement, not 1.0.

07/09/08 05:18:25 changed by garcia_marc

  • milestone set to post-1.0.

10/02/08 08:52:46 changed by bcurtu

I think there is a mistake in your patch yet.

There is an additional change you must do, because the patch fixes the calendar header, but not the number positions. So you must include an additional change, on line 64:

var startingPos = new Date(year, month-1, 1).getDay()-CalendarNamespace.firstDayOfWeek;

Add/Change #1061 (Start week day on calendar)




Change Properties
Action