Opened 13 years ago

Closed 7 years ago

#2320 closed task (wontfix)

Clock.js fix for PM/AM setttings, and handle 0.5 hour (30 minute) offset

Reported by: guest Owned by: Eugene Lazutkin
Priority: high Milestone: future
Component: DojoX GFX Version: 0.4.1
Keywords: needsreview Cc: Stacy.Thurston@…, greg.murray@…
Blocked By: Blocking:

Description (last modified by ben hockey)

Bug entered by: Stacy David Thurston of Sun Microsystems Email address: Stacy.Thurston@…

Below is updates you can use to fix the current version of Clock.js to handle:
1. Proper AM/PM settings. Fix is to add mod 24:
self.topLabelNode.innerHTML=(((self.date.getHours()+self.timeZoneOffset)%24)>11)?"PM":"AM";
2. 1/2 hours, 0.5 hour, 30 minute, offset, example: India's timeZoneOffset from California is 13.5.
var h=(self.date.getHours()+ self.timeZoneOffset - (self.timeZoneOffset % 1)) % 12;
var m=self.date.getMinutes() + ((self.timeZoneOffset % 1)*60);
3. Enhancement: add digital time:

// Digital display
var dH=(h<1)?12:h;
if (m>59) { dH=h+1; }
var dM=m % 60;
if (dM<10) { dM="0"+dM; }
self.topLabelNode.innerHTML=dH+":"+dM+" "+self.topLabelNode.innerHTML

Full code fix:

		this.draw=function(){
			//	summary: Moves the hands of the clock to the proper position based on the current date.
			self.date=new Date();
			var h=(self.date.getHours()+ self.timeZoneOffset - (self.timeZoneOffset % 1)) % 12;  // fix offset for India which is an 1/2 hour offset
			var m=self.date.getMinutes() + ((self.timeZoneOffset % 1)*60); // fix offset for India which is an 1/2 hour offset
			var s=self.date.getSeconds();

			self.placeHour(h, m, s);
			self.placeMinute(m, s);
			self.placeSecond(s);

                    // use mod 24 for PM/AM for world wide time zones.
                    self.topLabelNode.innerHTML=(((self.date.getHours()+self.timeZoneOffset)%24)>11)?"PM":"AM";

                    // Digital display
                    var dH=(h<1)?12:h;
                    if (m>59) { dH=h+1; }
                    var dM=m % 60;
                    if (dM<10) { dM="0"+dM; }
                    self.topLabelNode.innerHTML=dH+":"+dM+" "+self.topLabelNode.innerHTML
		};

Change History (13)

comment:1 Changed 13 years ago by Adam Peller

Cc: Stacy.Thurston@… added
Component: WidgetsDojox
Summary: Clock.js fix for PM/AM setttings, and handle 0.5 hour (30 minute) offset[cla needed]Clock.js fix for PM/AM setttings, and handle 0.5 hour (30 minute) offset

Stacy, have you signed a CLA? If not, we'll have to close this ticket.

comment:2 Changed 13 years ago by Adam Peller

Cc: greg.murray@… added

Greg, does Sun have a CCLA? If so, we can take this patch, though it would be great if someone were able to port Clock to dojox!

comment:3 Changed 13 years ago by Eugene Lazutkin

Owner: changed from bill to Eugene Lazutkin

I am porting dojo.gfx to 0.9. As soon as I am done, I'll look at porting the clock widget to dojox with included patches.

BTW, I think Sun has the CCLA.

comment:4 Changed 12 years ago by Eugene Lazutkin

Component: DojoxDojoX GFX
Status: newassigned

comment:5 Changed 12 years ago by Eugene Lazutkin

Milestone: 1.0

comment:6 Changed 12 years ago by Eugene Lazutkin

Type: defecttask

comment:7 Changed 12 years ago by Eugene Lazutkin

Summary: [cla needed]Clock.js fix for PM/AM setttings, and handle 0.5 hour (30 minute) offsetClock.js fix for PM/AM setttings, and handle 0.5 hour (30 minute) offset

comment:8 Changed 12 years ago by Adam Peller

So, doesn't Sun have a CCLA? Regardless, I'd suggest using dojo.date.locale and other dojo.date routines instead. This will enable proper local cultural conventions for 12 vs 24 hour time, proper 'am/pm' strings, etc. There are also routines in dojo.date to compute offsets if necessary for timezones.

comment:9 Changed 12 years ago by Eugene Lazutkin

Milestone: 1.02.0

comment:10 Changed 12 years ago by alex

Milestone: 2.01.3

Milestone 2.0 deleted

comment:11 Changed 11 years ago by Eugene Lazutkin

Milestone: 1.3future

Moving all open ticketd to the future.

comment:12 Changed 8 years ago by ben hockey

Description: modified (diff)
Keywords: needsreview added

is this ticket still relevant?

comment:13 Changed 7 years ago by dylan

Resolution: wontfix
Status: assignedclosed

Patch would need a significant rewrite to work today.

Closing as wontfix. Will review and commit if a new patch is provided.

Note: See TracTickets for help on using tickets.