Opened 14 years ago
Closed 8 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: | [email protected]…, [email protected]… |
Blocked By: | Blocking: |
Description (last modified by )
Bug entered by: Stacy David Thurston of Sun Microsystems Email address: [email protected]…
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 14 years ago by
Cc: | [email protected]… added |
---|---|
Component: | Widgets → Dojox |
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 |
comment:2 Changed 14 years ago by
Cc: | [email protected]… 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 14 years ago by
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 13 years ago by
Component: | Dojox → DojoX GFX |
---|---|
Status: | new → assigned |
comment:5 Changed 13 years ago by
Milestone: | → 1.0 |
---|
comment:6 Changed 13 years ago by
Type: | defect → task |
---|
comment:7 Changed 13 years ago by
Summary: | [cla needed]Clock.js fix for PM/AM setttings, and handle 0.5 hour (30 minute) offset → Clock.js fix for PM/AM setttings, and handle 0.5 hour (30 minute) offset |
---|
comment:8 Changed 13 years ago by
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 13 years ago by
Milestone: | 1.0 → 2.0 |
---|
comment:12 Changed 9 years ago by
Description: | modified (diff) |
---|---|
Keywords: | needsreview added |
is this ticket still relevant?
comment:13 Changed 8 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
Patch would need a significant rewrite to work today.
Closing as wontfix. Will review and commit if a new patch is provided.
Stacy, have you signed a CLA? If not, we'll have to close this ticket.