use of com.actiontech.dble.plan.common.time.MySQLTime in project dble by actiontech.
the class ItemFuncYearweek method valInt.
@Override
public BigInteger valInt() {
LongPtr year = new LongPtr(0);
long week;
MySQLTime ltime = new MySQLTime();
if (getArg0Date(ltime, MyTime.TIME_NO_ZERO_DATE))
return BigInteger.ZERO;
week = MyTime.calcWeek(ltime, (MyTime.weekMode(args.size() > 1 ? args.get(1).valInt().intValue() : 0) | MyTime.WEEK_YEAR), year);
return BigInteger.valueOf(week + year.get() * 100);
}
use of com.actiontech.dble.plan.common.time.MySQLTime in project dble by actiontech.
the class ItemTemporalHybridFunc method valStr.
@Override
public String valStr() {
MySQLTime ltime = new MySQLTime();
if (valDatetime(ltime, MyTime.TIME_FUZZY_DATE))
return null;
String res = MyTime.myTimeToStr(ltime, cachedFieldType == FieldTypes.MYSQL_TYPE_STRING ? (ltime.getSecondPart() != 0 ? MyTime.DATETIME_MAX_DECIMALS : 0) : decimals);
if (res == null)
nullValue = true;
return res;
}
use of com.actiontech.dble.plan.common.time.MySQLTime in project dble by actiontech.
the class ItemFuncDatediff method valInt.
@Override
public BigInteger valInt() {
MySQLTime ltime1 = new MySQLTime();
MySQLTime ltime2 = new MySQLTime();
if (args.get(0).isNullValue() || args.get(1).isNullValue() || args.get(0).getDate(ltime1, MyTime.TIME_FUZZY_DATE) || args.get(1).getDate(ltime2, MyTime.TIME_FUZZY_DATE)) {
nullValue = true;
return BigInteger.ZERO;
}
java.util.Calendar cal1 = ltime1.toCalendar();
java.util.Calendar cal2 = ltime2.toCalendar();
long diff = (cal1.getTimeInMillis() - cal2.getTimeInMillis()) / (24 * 3600);
return BigInteger.valueOf(diff);
}
use of com.actiontech.dble.plan.common.time.MySQLTime in project dble by actiontech.
the class CmpUtil method getDateFromStr.
/**
* @return converted value. 0 on error and on zero-dates -- check 'failure'
* @brief Convert date provided in a string to its packed temporal int
* representation.
* @param[in] thd thread handle
* @param[in] str a string to convert
* @param[in] warn_type type of the timestamp for issuing the warning
* @param[in] warn_name field name for issuing the warning
* @param[out] error_arg could not extract a DATE or DATETIME
* @details Convert date provided in the string str to the int
* representation. If the string contains wrong date or doesn't
* contain it at all then a warning is issued. The warn_type and
* the warn_name arguments are used as the name and the type of the
* field when issuing the warning.
*/
public static long getDateFromStr(String str, MySQLTimestampType warnType, String warnName, BoolPtr errorArg) {
MySQLTime lTime = new MySQLTime();
errorArg.set(getMysqlTimeFromStr(str, warnType, warnName, lTime));
if (errorArg.get())
return 0;
return MyTime.timeToLonglongDatetimePacked(lTime);
}
use of com.actiontech.dble.plan.common.time.MySQLTime in project dble by actiontech.
the class FieldTemporal method compareTo.
@Override
public int compareTo(final Field other) {
if (other == null || !(other instanceof FieldTemporal))
return 1;
FieldTemporal other2 = (FieldTemporal) other;
this.internalJob();
other2.internalJob();
MySQLTime ltime2 = other2.ltime;
return ltime.getCompareResult(ltime2);
}
Aggregations