
Hi Is there a bug in the old-locale package? I tried the following simple program: import Data.Time import System.Locale main = do time <- getCurrentTime putStrLn $ formatTime defaultTimeLocale rfc822DateFormat time The above program prints: Mon, d Apr 2009 15:23:56 UTC Notice "Mon, d", where "d" should be the day of the month. Looking at the source code in the package, I see: rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z" So what's up with %_d? -- Deniz Dogan

On Mon, Apr 20, 2009 at 11:27 PM, Deniz Dogan
Hi
Is there a bug in the old-locale package? I tried the following simple program:
import Data.Time import System.Locale
main = do time <- getCurrentTime putStrLn $ formatTime defaultTimeLocale rfc822DateFormat time
The above program prints:
Mon, d Apr 2009 15:23:56 UTC
Notice "Mon, d", where "d" should be the day of the month. Looking at the source code in the package, I see:
rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"
So what's up with %_d?
That looks like an error to me. According to the date(1) manpage, an underbar pads with spaces. % date +"%a, %_d %b %Y %H:%M:%S %Z" Tue, 21 Apr 2009 00:25:50 SGT /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

Magnus Therning wrote:
On Mon, Apr 20, 2009 at 11:27 PM, Deniz Dogan
wrote: Hi
Is there a bug in the old-locale package? I tried the following simple program:
import Data.Time import System.Locale
main = do time <- getCurrentTime putStrLn $ formatTime defaultTimeLocale rfc822DateFormat time
The above program prints:
Mon, d Apr 2009 15:23:56 UTC
Notice "Mon, d", where "d" should be the day of the month. Looking at the source code in the package, I see:
rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"
So what's up with %_d?
That looks like an error to me. According to the date(1) manpage, an underbar pads with spaces.
% date +"%a, %_d %b %Y %H:%M:%S %Z" Tue, 21 Apr 2009 00:25:50 SGT
It looks like old-locale and time have different ideas of date formats. Possibly this should be fixed in the time package. By the way, if old-locale is "old", what should be used instead? -- Ashley Yakeley

On Tue, Apr 21, 2009 at 4:31 PM, Ashley Yakeley
Magnus Therning wrote:
On Mon, Apr 20, 2009 at 11:27 PM, Deniz Dogan
wrote: Hi
Is there a bug in the old-locale package? I tried the following simple program:
import Data.Time import System.Locale
main = do time <- getCurrentTime putStrLn $ formatTime defaultTimeLocale rfc822DateFormat time
The above program prints:
Mon, d Apr 2009 15:23:56 UTC
Notice "Mon, d", where "d" should be the day of the month. Looking at the source code in the package, I see:
rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"
So what's up with %_d?
That looks like an error to me. According to the date(1) manpage, an underbar pads with spaces.
% date +"%a, %_d %b %Y %H:%M:%S %Z" Tue, 21 Apr 2009 00:25:50 SGT
It looks like old-locale and time have different ideas of date formats. Possibly this should be fixed in the time package.
By the way, if old-locale is "old", what should be used instead?
I'm not sure old means deprecated... at least not yet :-) /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe

On Tue, Apr 21, 2009 at 10:31 AM, Ashley Yakeley
Magnus Therning wrote:
On Mon, Apr 20, 2009 at 11:27 PM, Deniz Dogan
wrote: Hi
Is there a bug in the old-locale package? I tried the following simple program:
import Data.Time import System.Locale
main = do time <- getCurrentTime putStrLn $ formatTime defaultTimeLocale rfc822DateFormat time
The above program prints:
Mon, d Apr 2009 15:23:56 UTC
Notice "Mon, d", where "d" should be the day of the month. Looking at the source code in the package, I see:
rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"
So what's up with %_d?
That looks like an error to me. According to the date(1) manpage, an underbar pads with spaces.
% date +"%a, %_d %b %Y %H:%M:%S %Z" Tue, 21 Apr 2009 00:25:50 SGT
It looks like old-locale and time have different ideas of date formats. Possibly this should be fixed in the time package.
From reading the date(1) manpage, there are some other parts of the
old-time handles the padding by eating it. The attached patch does the same for the time package. format-spec not supported. But we at least parse the format-specs we ship with. Antoine

On Sun, 2009-06-28 at 19:46 -0500, Antoine Latter wrote:
old-time handles the padding by eating it. The attached patch does the same for the time package.
From reading the date(1) manpage, there are some other parts of the format-spec not supported. But we at least parse the format-specs we ship with.
I have decided to implement the glibc-specific formatting flags, "_-0^#". Do a "man strftime" on a glibc system to see. I compare with the system strftime as a test (which won't work on a non-glibc system, but I think that's OK). The trouble is that the glibc behaviour of "#" is bizarre. Sometimes it converts to upper case, sometimes it converts to lower case, and sometimes it does nothing. Despite what the man page says, it never "swaps" the case, even for %Z. I am tempted to have "#" always convert to lower case. This is the most predictable and useful behaviour. -- Ashley Yakeley
participants (4)
-
Antoine Latter
-
Ashley Yakeley
-
Deniz Dogan
-
Magnus Therning