}
protected static RubyTime s_mload(IRubyObject recv, RubyTime time, IRubyObject from) {
Ruby runtime = recv.getRuntime();
DateTime dt = new DateTime(DateTimeZone.UTC);
byte[] fromAsBytes = null;
fromAsBytes = from.convertToString().getBytes();
if(fromAsBytes.length != 8) {
throw runtime.newTypeError("marshaled time format differ");
}
int p=0;
int s=0;
for (int i = 0; i < 4; i++) {
p |= ((int)fromAsBytes[i] & 0xFF) << (8 * i);
}
for (int i = 4; i < 8; i++) {
s |= ((int)fromAsBytes[i] & 0xFF) << (8 * (i - 4));
}
if ((p & (1<<31)) == 0) {
dt = dt.withMillis(p * 1000L + s);
} else {
p &= ~(1<<31);
dt = dt.withYear(((p >>> 14) & 0xFFFF) + 1900);
dt = dt.withMonthOfYear(((p >>> 10) & 0xF) + 1);
dt = dt.withDayOfMonth(((p >>> 5) & 0x1F));
dt = dt.withHourOfDay((p & 0x1F));
dt = dt.withMinuteOfHour(((s >>> 26) & 0x3F));
dt = dt.withSecondOfMinute(((s >>> 20) & 0x3F));
// marsaling dumps usec, not msec
dt = dt.withMillisOfSecond((s & 0xFFFFF) / 1000);
dt = dt.withZone(getLocalTimeZone(runtime));
time.setUSec((s & 0xFFFFF) % 1000);
}
time.setDateTime(dt);
from.getInstanceVariables().copyInstanceVariablesInto(time);