Fix a bug that 1969-12-31 23:59:59 UTC (Unix time: -1) causes an error

Redmine: fixes #2551