Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix incorrect date header when in a timezone with +/- 30 mins #56

Merged
merged 1 commit into from

2 participants

@pedrosland

Date headers should be like
Tue, 15 Jan 2013 14:45:11 -0430
but are like
Tue, 15 Jan 2013 14:45:16 -0450

For info on a time zone with a 30 min difference see http://www.timeanddate.com/library/abbreviations/timezones/sa/vet.html

The original bug for including the date header had it correct with dateFormat but neither the Z or ZZ in moment are quite the same. My proposed fix isn't very elegant but it seems to work.

@eleith
Owner

why do you think it isn't very elegant?

@pedrosland

It just feels a little awkward to have to ask for another date format and then use replace on it. It would be prettier just to do .moment('ddd, DD MMM YYYY HH:mm:ss X') or something but I don't think we want to add another placeholder to moment.js.

Note: X = unix timestamp in moment.js.

@eleith
Owner

why does moment.format("ZZ") not work?

@eleith
Owner

also, what about using moment().zone() ? http://momentjs.com/docs/#/manipulating/timezone-offset/

@pedrosland

RFC2822 says that time zones should be hhmm (page 14). The information here under "Email time zone indicator" supports my interpretation.

ZZ doesn't work as it gets the offset in hhff where ff = fraction of hour (50 instead of 30 minutes).

We could calculate it by getting the current zone (.zone()) and then extracting hours and minutes but personally, I prefer the .replace() method.

I created a fiddle to show this in action http://jsfiddle.net/pedro_sland/dzkqV/1/.

@eleith eleith merged commit 9599399 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  smtp/message.js
View
2  smtp/message.js
@@ -35,7 +35,7 @@ var Message = function(headers)
var now = new Date();
this.header = {
"message-id":"<" + now.getTime() + "." + (counter++) + "." + process.pid + "@" + os.hostname() +">",
- "date":moment().format("ddd, DD MMM YYYY HH:mm:ss ZZ")
+ "date":moment().format("ddd, DD MMM YYYY HH:mm:ss ") + moment().format("Z").replace(/:/, '')
};
this.content = "text/plain; charset=utf-8";
Something went wrong with that request. Please try again.