dst bug in c-client
| From: | Jade Nicoletti | Date: | Mon, 27 Mar 2000 09:41:21 +0000 |
| Subject: | dst bug in c-client | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12667@lists.php.net to get a copy of this message | ||
Hi
To build a workaround to a bug in the c-client lib, it requires a way to
determine if a unix timestamp is in daylight saving time or not.
# workaround for udate (which doesn't handle is_dst)
$receipt_date = $imap_header->udate;
$inow = date('I');
$ird = date('I', $receipt_date);
if ($ird && !$inow) $receipt_date -= 3600;
elseif (!$ird && $inow) $receipt_date += 3600;
# $receipt_date should now contain the correct timestamp
The patch for the dates 'I' implementation is attached. Please commit it to
the CVS or give me a better way to get the correct timestamp.
Thanks in advance.
-Jade.
--- datetime.c~ Sun Mar 12 16:47:32 2000 +++ datetime.c Sun Mar 26 18:14:29 2000 @@ -270,6 +270,7 @@ size += 3; break; case 'w': /* day of the week, numeric */ + case 'I': /* daylight saving time */ default: size++; break; @@ -418,6 +419,10 @@ ((((long)the_time) % 86400) + 3600))) * 10) / 864); if (beat > 999) beat = 0; sprintf(tmp_buff, "%03d", beat); /* SAFE */ + strcat(return_value->value.str.val, tmp_buff); + break; + case 'I': /* daylight saving time */ + sprintf(tmp_buff, "%d", ta->tm_isdst); strcat(return_value->value.str.val, tmp_buff); break; default:
--- datetime.c~ Sun Mar 12 16:47:32 2000 +++ datetime.c Sun Mar 26 18:14:29 2000 @@ -270,6 +270,7 @@ size += 3; break; case 'w': /* day of the week, numeric */ + case 'I': /* daylight saving time */ default: size++; break; @@ -418,6 +419,10 @@ ((((long)the_time) % 86400) + 3600))) * 10) / 864); if (beat > 999) beat = 0; sprintf(tmp_buff, "%03d", beat); /* SAFE */ + strcat(return_value->value.str.val, tmp_buff); + break; + case 'I': /* daylight saving time */ + sprintf(tmp_buff, "%d", ta->tm_isdst); strcat(return_value->value.str.val, tmp_buff); break; default: