nwixsom / gwt-cal

Automatically exported from code.google.com/p/gwt-cal
0 stars 0 forks source link

Allow choosing the first day of the week #35

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Description of the new feature:
Different countries define different week starting days. The calendar should 
allow changing this property to mach the current country settings

Code / psuedo-code:
Maybe something like:
CalendarSettings.setFirstDayOfWeek(Calendar.Weekdays.MONDAY)

(see java.util.Calendar.setFirstDayOfWeek(int value))

Original issue reported on code.google.com by uzi.land...@gmail.com on 9 Mar 2010 at 8:07

GoogleCodeExporter commented 9 years ago
Hello Uzi,

I just finished with a preliminary implementation of this feature. It will be
available in two ways:

a) As a property in the i18n localization file (CalendarConstants.properaties). 
By
defining a value for the property 'firstDayOfWeek' in the project properties 
file
you'll be able to set the day weeks begin on in the month view (Sunday - 0, 
Monday -
1, Tuesday - 2, and so on). 

b) Programatically overriding the calendar formatting property at runtime. We 
just
added a way that allows you to programatically modify the properties configured
through the i18n project properties file. In order to programatically set the 
first
day of the week, you will need to make a call such as

com.bradrydzewski.gwt.calendar.client.CalendarFormat.INSTANCE.setFirstDayOfWeek(
1);

  before preparing your Calendar object in the Java code.

Please bear in mind that this second approach is something I still need to 
discuss
with Brad Rydzewski. The way to access the CalendarFormat.INSTANCE and override 
the
value COULD DRASTICALLY CHANGE. 

In the meantime, you can test drive these changes as of revision 270.

Original comment by carlos.m...@gmail.com on 19 Mar 2010 at 4:35

GoogleCodeExporter commented 9 years ago

Original comment by carlos.m...@gmail.com on 19 Mar 2010 at 4:47

GoogleCodeExporter commented 9 years ago
I've been playing with these changes and I found different problems:

- If I really want to remove the AM/PM I need to:
      String[] hourLabels = new String[]{"12:00", "1:00", "2:00", "3:00",
      "4:00", "5:00", "6:00", "7:00", "8:00", "9:00", "10:00",
      "11:00", "12:00", "1:00", "2:00", "3:00", "4:00", "5:00",
      "6:00", "7:00", "8:00", "9:00", "10:00", "11:00"};

        CalendarFormat.INSTANCE.setAm("");
        CalendarFormat.INSTANCE.setHourLabels(hourLabels);

But even with that I still get a "12:00 pm"

I would expect that doing the setAm("") it automatically removes the AM/PM, but 
seems
that the CalendarFormat.generateHourLabels() is automatically generating the 
hours
with the AM/PM suffix, and there's no public method to regenerate these labels.

Also I see that the CalendarFormat.setFirstDayOfWeek() is still not having any 
effect.

Finally, the whole CalendarFormat seems like a good approach, but I'm missing 
some
wrapping in the CalendarSettings to make everything easier to use.

My 2 cents.

Original comment by ctasada on 21 Mar 2010 at 3:49

GoogleCodeExporter commented 9 years ago
There was a bug in generateHourLabels(). It was ALWAYS using SimpleDateFormat 
instead 
of using the internationalized formats in the properties files. That is why you 
were 
always seeing "12:00 pm" for example, instead of "Noon" as intended.

We can set the firstDayOfWeek in the MonthView through internationalized 
properties 
files, as well as setting manually:
CalendarFormat.INSTANCE.setFirstDayOfWeek(1);

Original comment by Brad.Ryd...@gmail.com on 27 Mar 2010 at 10:21

GoogleCodeExporter commented 9 years ago

Original comment by Brad.Ryd...@gmail.com on 12 May 2010 at 7:07