[imp] Small bug in generateMbox

Michael M Slusarz slusarz at bigworm.colorado.edu
Fri Oct 31 17:36:36 PST 2003


Quoting Andrew Morgan <morgan at orst.edu>:

|
| There is a small bug in the generateMbox() function in lib/Folders.php.
| The following code is used to generate the "From " message separate line
| in an mbox file:
|
|                    $date = date('D M j H:i:s Y', $h->udate);
|                    $body .= 'From ' . $from . ' ' . $date . "\n";
|
| Which generates a From line like:
|
|   From foo at oregonstate.edu Tue Sep 2 09:18:39 2003
|
| However, Pine will only "see" the message if the day of the month has a
| leading space.  The correct form for the line should be:
|
|   From foo at oregonstate.edu Tue Sep  2 09:18:39 2003
|
| (note the extra space between "Sep" and "2")
|
| I don't see any direct way to do this with php's date() function.  The
| only possibility I can come up with for adding a leading space would be
| to
| use a sprintf, maybe like so:
|
|    $date = sprintf('%s %2s %s', date('D M', $h->udate), date('j',
| $h->udate), date('H:i:s Y', $h->udate));

Well, strftime() supports exactly what we need:
%e - day of the month as a decimal number, a single digit is preceded by a
space (range ' 1' to '31')
...except that, since it it locale specific, it may use non-English
abbrevations for the Month name.  So that's out.  Looks like your solution,
as ugly as it may be, is the most correct. :)

Committed to CVS.

michael

______________________________________________
Michael Slusarz [slusarz at bigworm.colorado.edu]
The University of Colorado at Boulder


More information about the imp mailing list