> Good idea. But how about we set the Date: to that directly?
> Currently Twidge doesn't set Date but it sounds useful to do so.
> Your thoughts?
I wrote a small patch that adds this header. I am using it and it
seems to handle the email subproblem.
The associated pull request on github :
https://github.com/jgoerzen/twidge/pull/24
Cheers
--
Etienne Millon
diff --git a/Commands/Ls.hs b/Commands/Ls.hs
index 9942882..2de280c 100644
--- a/Commands/Ls.hs
+++ b/Commands/Ls.hs
@@ -38,6 +38,9 @@ import System.Console.GetOpt.Utils
import Network.URI
import Data.Maybe (isJust)
import Network.OAuth.Http.Request
+import Data.Time.Format (formatTime, parseTime)
+import Data.Time.LocalTime (ZonedTime)
+import System.Locale (defaultTimeLocale, rfc822DateFormat)
i = infoM "ls"
@@ -328,6 +331,10 @@ mailto section cp args m recipient =
Right x -> ["From: " ++ (sSender m) ++ " <" ++ x ++ ">",
"Subject: " ++ subject]
) ++
+ (case twitterToRFC822 (sDate m) of
+ Just d -> [ "Date: " ++ d ]
+ Nothing -> []
+ ) ++
["Message-ID: " ++ msgid,
"X-Twidge-urlbase: " ++ forceEither (get cp "DEFAULT" "urlbase"),
"X-Twidge-server-base: " ++ serverHost cp,
@@ -349,6 +356,11 @@ mailto section cp args m recipient =
escapeURIString isUnreserved (sSender m)
,"User home: http://twitter.com/" ++ sSender m
]
+ twitterToRFC822 d =
+ formatTime defaultTimeLocale rfc822DateFormat `fmap` time
+ where
+ time :: Maybe ZonedTime
+ time = parseTime defaultTimeLocale "%a %b %e %H:%M:%S %Z %Y" d
----------------------------------------------------------------------
-- Follow/block type commands
diff --git a/twidge.cabal b/twidge.cabal
index 896e0a0..301c579 100644
--- a/twidge.cabal
+++ b/twidge.cabal
@@ -50,7 +50,7 @@ Executable twidge
Build-Depends: network, unix, parsec, MissingH>=1.0.0,
mtl, base >= 4 && < 5, HaXml>=1.13.2, HaXml<1.19, hslogger, hoauth>=0.2.3 && <0.2.4,
ConfigFile, directory, HSH, regex-posix, utf8-string, binary,
- bytestring, curl
+ bytestring, curl, old-locale, time
if flag(withBitly)
Build-Depends: Bitly