Skip to content

Commit

Permalink
Merge b2095cb into cd402f3
Browse files Browse the repository at this point in the history
  • Loading branch information
timgarrels committed Jul 19, 2019
2 parents cd402f3 + b2095cb commit ab07893
Show file tree
Hide file tree
Showing 19 changed files with 60 additions and 34 deletions.
1 change: 1 addition & 0 deletions packages/IMAPClient-Core.package/ICEmail.class/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Instance Variables
body: The body of the ICEmail. ICEmail>>retrieveBody needs to be called to fill the body.
folder: The ICFolder this ICEmail resides in.
header: The header of the ICEmail. This gets parsed into the instance variables date, from, to and subject.
date: https://tools.ietf.org/html/rfc2822#page-14, date represents the local time and the zone is the timezone information.

Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
accessing
dateFormatted

"Use date in header and convert it into seconds with MailMessage timeFrom Method.
Add localOffset to keep it in LocalTime.
Need to add 1.1.1980 because DateAndTime starts there."

| date formatted |

self date = '' ifTrue: [^''].

date := DateAndTime fromSeconds: self dateInSeconds.

date := DateAndTime fromSeconds: self dateInSecondsSinceSqueakEpoch + DateAndTime localOffset asSeconds.

formatted := ((date dayOfMonth asString padded: #left to: 2 with: $0) ,'.',
(date month asString padded: #left to: 2 with: $0), '.',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
accessing
dateInSecondsSince1980
"MailMessage parses in UTC"

^ MailMessage new timeFrom: self date
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
dateInSecondsSinceSqueakEpoch

^ self dateInSecondsSince1980 + (DateAndTime year: 1980 day: 1) asSeconds
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@
"contentType:" : "C.G. 7/25/2018 13:46",
"date" : "C.G. 7/25/2018 13:46",
"date:" : "C.G. 7/25/2018 13:46",
"dateFormatted" : "pm 6/2/2019 15:56",
"dateInSeconds" : "pm 6/2/2019 15:56",
"dateFormatted" : "tg 7/19/2019 11:31",
"dateInSecondsSince1980" : "tg 7/19/2019 10:34",
"dateInSecondsSinceSqueakEpoch" : "tg 7/19/2019 10:35",
"deleteEmail" : "C.G. 7/12/2018 08:07",
"deleteEmailFromDisk" : "pm 6/2/2019 15:58",
"deleted" : "DH 7/19/2018 21:58",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
],
"classvars" : [
],
"commentStamp" : "ms 7/28/2016 11:29",
"commentStamp" : "tg 7/19/2019 10:33",
"instvars" : [
"body",
"header",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
accessing
emails

^ emails ifNil: [emails := (SortedCollection sortBlock: [:first :second | first dateInSeconds >= second dateInSeconds])]
^ emails ifNil: [emails := (SortedCollection sortBlock: [:first :second | first dateInSecondsSinceSqueakEpoch >= second dateInSecondsSinceSqueakEpoch])]
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"childFolders" : "pm 6/9/2019 13:12",
"childFolders:" : "js 6/7/2016 11:32",
"countFolders" : "C.G. 7/25/2018 14:02",
"emails" : "pm 6/9/2019 13:13",
"emails" : "tg 7/19/2019 09:02",
"emails:" : "ms 6/28/2016 09:52",
"endpoint" : "ms 7/10/2016 13:24",
"endpoint:" : "pm 6/9/2019 16:56",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
emailDate

^ DateAndTime year: 2016 month: 6 day: 10 hour: 10 minute: 51 second: 42
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
expected1980Seconds

^ self emailDate asSeconds - (DateAndTime year: 1980 day: 1) asSeconds

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
expectedParsedMESZDate

^ '10.06.2016 12:51'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
expectedParsedUTCDate

^ '10.06.2016 10:51'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
constants
expectedSqueakEpochSeconds

^ self emailDate asSeconds
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ testDateFormatted

previousOffset := DateAndTime localOffset.

"use 'Mitteleuropäische Sommerzeit' "
DateAndTime localOffset: (Duration fromString: '0:02:00:00').
"use UTC (Coordinated Universal Time)"
DateAndTime localOffset: (Duration fromString: '0:00:00:00').
self assert: self email dateFormatted equals: self class expectedParsedUTCDate.

self assert: self email dateFormatted equals: self class expectedParsedDate.
"use Mitteleuropäische Sommerzeit"
DateAndTime localOffset: (Duration fromString: '0:02:00:00').
self assert: self email dateFormatted equals: self class expectedParsedMESZDate.

DateAndTime localOffset: previousOffset
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
testDateInSecondsSince1980

self assert: self email dateInSecondsSince1980 equals: self class expected1980Seconds.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
testDateInSecondsSinceSqueakEpoch

self assert: self email dateInSecondsSinceSqueakEpoch equals: self class expectedSqueakEpochSeconds.
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
{
"class" : {
"emailDate" : "tg 7/19/2019 12:40",
"expected1980Seconds" : "tg 7/19/2019 09:33",
"expectedBody" : "DH 6/9/2018 15:33",
"expectedMinimalHeaderAsString" : "DH 6/9/2018 15:32",
"expectedParsedDate" : "DH 6/6/2018 19:52",
"expectedParsedMESZDate" : "tg 7/19/2019 10:36",
"expectedParsedUTCDate" : "tg 7/19/2019 10:36",
"expectedSqueakEpochSeconds" : "tg 7/19/2019 09:29",
"expectedStringRepresentation" : "DH 6/9/2018 15:23" },
"instance" : {
"email" : "C.G. 7/25/2018 17:52",
"email:" : "pm 6/9/2019 17:16",
"setUp" : "C.G. 7/25/2018 17:53",
"testAsString" : "mw 5/11/2018 12:06",
"testDateFormatted" : "pm 6/3/2019 18:52",
"testDateFormatted" : "tg 7/19/2019 08:36",
"testDateInSecondsSince1980" : "tg 7/19/2019 09:26",
"testDateInSecondsSinceSqueakEpoch" : "tg 7/19/2019 09:27",
"testMinimalHeaderAsString" : "C.G. 7/25/2018 17:53",
"testRetrieveBody" : "DH 7/9/2018 15:39" } }

0 comments on commit ab07893

Please sign in to comment.