Skip to content

Commit c0b42a9

Browse files
author
jgillula
committed
Version 1.0.1:
* Fix a bug where days were calculated based on time in UTC, not the local timezone * Make clearer what the default date format does
1 parent e32bb2a commit c0b42a9

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

src/chrome/content/enhancedDateFormatter.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@ EnhancedDateFormatter.getDateFormatForDate = function (date) {
1212
// January 1, 1970, UTC, and there are 86400000 in a day, so
1313
// to get the number of days, just divide by 86400000 and
1414
// floor the result
15-
var todayDay = Math.floor((new Date()).valueOf()/86400000);
16-
var dateDay = Math.floor(date.valueOf()/86400000);
15+
16+
// Additionally, in order to correct for the timezone (so we're
17+
// not getting day numbers in UTC), we need to subtract off the
18+
// timezone offset (which is given in minutes, so we need to
19+
// multiply by 60000 to get milliseconds)
20+
var todayDate = new Date();
21+
var todayDay = Math.floor((todayDate.valueOf()-todayDate.getTimezoneOffset()*60000)/86400000);
22+
var dateDay = Math.floor((date.valueOf()-date.getTimezoneOffset()*60000)/86400000);
1723

1824
if (EnhancedDateFormatter.preferences.getValue('useCustomFormatForLastWeek', false) &&
1925
dateDay > (todayDay-6)) {

src/chrome/content/preferences.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function setDisabledOrEnabled(ids, value) {
1111
}
1212

1313
EnhancedDateFormatter.adjustDisabledStates = function() {
14-
setDisabledOrEnabled(["label_defaultDateFormat", "textbox_defaultDateFormat",
14+
setDisabledOrEnabled(["label_defaultDateFormat", "description_defaultDateFormat", "textbox_defaultDateFormat",
1515
"checkbox_useCustomFormatForToday",
1616
"checkbox_useCustomFormatForYesterday",
1717
"checkbox_useCustomFormatForLastWeek"],

src/chrome/content/preferences.xul

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,15 @@
6767

6868
<description style="font-weight: bold">Note: To view your changes, you may need to restart Thunderbird.</description>
6969

70-
<hbox>
71-
<label id="label_defaultDateFormat" control="textbox_defaultDateFormat" value="Default date format:" />
70+
<hbox align="center">
71+
<vbox>
72+
<label id="label_defaultDateFormat" control="textbox_defaultDateFormat">
73+
Default date format:
74+
</label>
75+
<description id="description_defaultDateFormat">
76+
(For any date not covered by one of the conditions below)
77+
</description>
78+
</vbox>
7279
<textbox id="textbox_defaultDateFormat" preference="extensions.enhancedDateFormatter.defaultDateFormat"/>
7380
</hbox>
7481

src/install.rdf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<Description about="urn:mozilla:install-manifest">
77
<em:id>enhanceddateformatter@jeremy.gillula</em:id>
8-
<em:version>1.0.0</em:version>
8+
<em:version>1.0.1</em:version>
99
<em:type>2</em:type>
1010
<em:targetApplication>
1111
<Description>

0 commit comments

Comments
 (0)