Skip to content

Commit

Permalink
MSSQL datetime4 handling is the same as Sybase, only datetime8 differs
Browse files Browse the repository at this point in the history
(cherry picked from commit bf20b64)
  • Loading branch information
thekid authored and treuter committed Dec 21, 2018
1 parent 44b8438 commit 935ae27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 5 additions & 0 deletions src/main/php/rdbms/tds/TdsProtocol.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,11 @@ public function unmarshal($stream, $field, $records) {
return $this->toDate($stream->getLong(), 0);
}
}');
self::$recordsFor[0][self::T_DATETIME4]= newinstance('rdbms.tds.TdsRecord', [], '{
public function unmarshal($stream, $field, $records) {
return $this->toDate($stream->getShort(), $stream->getShort() * 60);
}
}');
self::$recordsFor[0][self::T_DATETIME]= newinstance('rdbms.tds.TdsRecord', [], '{
public function unmarshal($stream, $field, $records) {
return $this->toDate($stream->getLong(), $stream->getLong() / 300);
Expand Down
5 changes: 0 additions & 5 deletions src/main/php/rdbms/tds/TdsV5Protocol.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ public function unmarshal($stream, $field, $records) {
}
}
}');
self::$recordsFor[0][self::T_DATETIME4]= newinstance('rdbms.tds.TdsRecord', [], '{
public function unmarshal($stream, $field, $records) {
return $this->toDate($stream->getShort(), $stream->getShort() * 60);
}
}');
self::$recordsFor[0][self::T_DATETIMN]= newinstance('rdbms.tds.TdsRecord', [], '{
public function unmarshal($stream, $field, $records) {
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
Expand Down
7 changes: 1 addition & 6 deletions src/main/php/rdbms/tds/TdsV7Protocol.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,11 @@ public function unmarshal($stream, $field, $records) {
return 0xFFFF === $len ? null : iconv("ucs-2le", \xp::ENCODING, $stream->read($len));
}
}');
self::$recordsFor[0][self::T_DATETIME4]= newinstance('rdbms.tds.TdsRecord', [], '{
public function unmarshal($stream, $field, $records) {
return $this->toDate($stream->getShort(), $stream->getShort() * 60 / 300);
}
}');
self::$recordsFor[0][self::T_DATETIMN]= newinstance('rdbms.tds.TdsRecord', [], '{
public function unmarshal($stream, $field, $records) {
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
switch ($len) {
case 4: return $this->toDate($stream->getShort(), $stream->getShort() * 60 / 300); break;
case 4: return $this->toDate($stream->getShort(), $stream->getShort() * 60; break;
case 8: return $this->toDate($stream->getLong(), $stream->getLong() / 300); break;
default: return null;
}
Expand Down

0 comments on commit 935ae27

Please sign in to comment.