示例#1
0
func dateTimeVarGetValue(v *Variable, pos uint) (interface{}, error) {
	var (
		year                             C.sb2
		month, day, hour, minute, second C.ub1
	)
	/*
		err := v.environment.CheckStatus(
			C.OCIDateGetDate(&v.dataBytes[pos*sizeof_OCIDate], &year, &month, &day),
			"OCIDateGetDate")
		if err != nil {
			return nil, err
		}
		if err = v.environment.CheckStatus(
			C.OCIDateGetTime(&v.dataBytes[pos*sizeof_OCIDate], &hour, &minute, &second),
			"OCIDateGetTime"); err != nil {
			return nil, err
		}
	*/
	C.getDateTime((*C.OCIDate)(v.getHandle(pos)),
		&year, &month, &day, &hour, &minute, &second)
	/*
		    fmt.Printf("%s[%d]: %d-%d-%d %d:%d:%d = %s", v, pos,
				year, month, day, hour, minute, second,
				time.Date(int(year), time.Month(month), int(day),
					int(hour), int(minute), int(second), 0, time.Local).Format(time.RFC3339))
	*/
	if year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0 {
		return time.Time{}, nil
	}
	return time.Date(int(year), time.Month(month), int(day),
		int(hour), int(minute), int(second), 0, time.Local), nil
}
示例#2
0
func dateTimeVarIsNull(v *Variable, pos uint) bool {
	var (
		year                             C.sb2
		month, day, hour, minute, second C.ub1
	)
	C.getDateTime((*C.OCIDate)(v.getHandle(pos)),
		&year, &month, &day, &hour, &minute, &second)
	return year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0
}
示例#3
0
func dateTimeVarGetValue(v *Variable, pos uint) (interface{}, error) {
	var (
		year                             C.sb2
		month, day, hour, minute, second C.ub1
	)
	/*
		err := v.environment.CheckStatus(
			C.OCIDateGetDate(&v.dataBytes[pos*sizeof_OCIDate], &year, &month, &day),
			"OCIDateGetDate")
		if err != nil {
			return nil, err
		}
		if err = v.environment.CheckStatus(
			C.OCIDateGetTime(&v.dataBytes[pos*sizeof_OCIDate], &hour, &minute, &second),
			"OCIDateGetTime"); err != nil {
			return nil, err
		}
	*/
	C.getDateTime((*C.OCIDate)(v.getHandle(pos)),
		&year, &month, &day, &hour, &minute, &second)
	return time.Date(int(year), time.Month(month), int(day),
		int(hour), int(minute), int(second), 0, time.Local), nil
}