Skip to content

Commit edb6c8e

Browse files
thekidtreuter
authored andcommitted
MSSQL datetime4 handling is the same as Sybase, only datetime8 differs
(cherry picked from commit bf20b64)
1 parent 664c417 commit edb6c8e

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/main/php/rdbms/tds/TdsProtocol.class.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ public function unmarshal($stream, $field, $records) {
214214
return $this->toDate($stream->getLong(), 0);
215215
}
216216
}');
217+
self::$recordsFor[0][self::T_DATETIME4]= newinstance('rdbms.tds.TdsRecord', [], '{
218+
public function unmarshal($stream, $field, $records) {
219+
return $this->toDate($stream->getShort(), $stream->getShort() * 60);
220+
}
221+
}');
217222
self::$recordsFor[0][self::T_DATETIME]= newinstance('rdbms.tds.TdsRecord', [], '{
218223
public function unmarshal($stream, $field, $records) {
219224
return $this->toDate($stream->getLong(), $stream->getLong() / 300);

src/main/php/rdbms/tds/TdsV5Protocol.class.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,6 @@ public function unmarshal($stream, $field, $records) {
9191
}
9292
}
9393
}');
94-
self::$recordsFor[0][self::T_DATETIME4]= newinstance('rdbms.tds.TdsRecord', [], '{
95-
public function unmarshal($stream, $field, $records) {
96-
return $this->toDate($stream->getShort(), $stream->getShort() * 60);
97-
}
98-
}');
9994
self::$recordsFor[0][self::T_DATETIMN]= newinstance('rdbms.tds.TdsRecord', [], '{
10095
public function unmarshal($stream, $field, $records) {
10196
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();

src/main/php/rdbms/tds/TdsV7Protocol.class.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,11 @@ public function unmarshal($stream, $field, $records) {
114114
return 0xFFFF === $len ? null : iconv("ucs-2le", \xp::ENCODING, $stream->read($len));
115115
}
116116
}');
117-
self::$recordsFor[0][self::T_DATETIME4]= newinstance('rdbms.tds.TdsRecord', [], '{
118-
public function unmarshal($stream, $field, $records) {
119-
return $this->toDate($stream->getShort(), $stream->getShort() * 60 / 300);
120-
}
121-
}');
122117
self::$recordsFor[0][self::T_DATETIMN]= newinstance('rdbms.tds.TdsRecord', [], '{
123118
public function unmarshal($stream, $field, $records) {
124119
$len= isset($field["len"]) ? $field["len"] : $stream->getByte();
125120
switch ($len) {
126-
case 4: return $this->toDate($stream->getShort(), $stream->getShort() * 60 / 300); break;
121+
case 4: return $this->toDate($stream->getShort(), $stream->getShort() * 60; break;
127122
case 8: return $this->toDate($stream->getLong(), $stream->getLong() / 300); break;
128123
default: return null;
129124
}

0 commit comments

Comments
 (0)