List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:June 19 2001 11:56pm
Subject:Re: unix_timestamp why 0
View as plain text  
At 11:04 PM +0200 6/19/01, Attila Soki wrote:
>| Paul DuBois [mailto:paul@stripped]
>| When UNIX_TIMESTAMP is used on a TIMESTAMP column, the function will
>| receive the value directly, with no implicit
>| ``string-to-unix-timestamp'' conversion. If you give UNIX_TIMESTAMP() a
>| wrong or out-of-range date, it will return 0.
>
>second test:
>
>c with dates before 1970:
>---cut here ---
>#include <stdio.h>
>#include <time.h>
>
>int main(void)
>{
>	struct tm time_check;
>	time_t xtime;
>	char str[80];
>	int ts;
>
>	//1969-1-1 00:00:01
>	time_check.tm_year = 1969 - 1900;
>	time_check.tm_mon  = 1 - 1;
>	time_check.tm_mday = 1;
>	time_check.tm_hour = 0;
>	time_check.tm_min  = 0;
>	time_check.tm_sec  = 1;
>	time_check.tm_isdst = -1;
>
>	xtime=mktime(&time_check);
>	strftime(str, 80,"%#c",&time_check);
>	printf("time: %s\n",str);
>	return 0;
>}
>---cut here ---
>
>and the output:
>alpha:/home/atiware# ./ut
>time: Wed Jan  1 00:00:01 1969
>alpha:/home/atiware#
>
>same in MySql:
>mysql> select unix_timestamp('1969-1-1 00:00:01');                  
>+-------------------------------------+
>| unix_timestamp('1969-1-1 00:00:01') |
>+-------------------------------------+
>|                                   0 |
>+-------------------------------------+
>1 row in set (0.00 sec)
>
>
>why can C work with this date, and mysql why not?
>is this a bug or not?

It's a bug that MySQL performs as documented?

Does that C program work on all platforms where MySQL works?


>thanks.
>
>ati

-- 
Paul DuBois, paul@stripped
Thread
unix_timestamp why 0Attila Soki19 Jun
  • Re: unix_timestamp why 0Paul DuBois19 Jun
    • Re: unix_timestamp why 0Attila Soki19 Jun
      • Re: unix_timestamp why 0Paul DuBois20 Jun