xibejian's patch for datetime issues