hpdatetime.java
来自「一个简单的visio程序。」· Java 代码 · 共 2,210 行 · 第 1/5 页
JAVA
2,210 行
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(exp);
return (short)(tm.dt_month);
}
public static short MONTH(HCurr exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp.dblValue();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_month);
}
public static short MONTH(HDate exp) throws HpException
{
double dbl = exp.dblValue();
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_month);
}
public static short MONTH(fixedString exp) throws HpException
{
double dbl = getdt_db(new VString(exp.strValue() ) );
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_month);
}
public static short MONTH(String exp) throws HpException
{
double dbl = getdt_db( (Variant)(new VString(exp) ));
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_month);
}
/**
*Day(date)
*Returns a whole number between 1 and 31,inclusive,representing the day of the
*month.if date contain null then return null.
*/
public static Variant DAY(Variant exp) throws HpException
{
HCDateTimeStruct tm;
Variant v = null;
int type = exp.getType();
if( type==Variant.V_NULL)
{
v = new VNull();
}
else
{
double dbl = getdt_db( exp);
tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
v = new VInt( (short)tm.dt_mday );
}
return v;
}
public static short DAY(boolean exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp==true ? (double)-1:(double)0;
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_mday);
}
public static short DAY(HByte exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)(exp.byteValue() ));
return (short)(tm.dt_mday);
}
public static short DAY(short exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_mday);
}
public static short DAY(int exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_mday);
}
public static short DAY(float exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_mday);
}
public static short DAY(double exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(exp);
return (short)(tm.dt_mday);
}
public static short DAY(HCurr exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp.dblValue();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_mday);
}
public static short DAY(HDate exp) throws HpException
{
double dbl = exp.dblValue();
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_mday);
}
public static short DAY(fixedString exp) throws HpException
{
double dbl = getdt_db(new VString(exp.strValue() ) );
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_mday);
}
public static short DAY(String exp) throws HpException
{
double dbl = getdt_db( new VString(exp) );
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_mday);
}
/**
*WeekDay(date,firstdayofweek)
*Returns a whole number representing the day of the week.
*date Numeric or string expression, in any combination, that can represent a
date. If date contains Null, Null is returned.
*firstdayofweek A constant that specifies the first day of the week, as
described in Settings. If omitted, vbSunday is assumed.
*/
public static Variant WEEKDAY(Variant exp ,Variant firstdayofweek) throws HpException
{
HCDateTimeStruct tm;
short weekday;
int tmp=0;
Variant v = null;
int type = exp.getType();
if( type==Variant.V_NULL)
{
v = new VNull();
}
else
{
double dbl = getdt_db( exp);
tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
weekday = (short)tm.dt_week;
int firstday = hpstring.dbl2int( hpstring.get_db( firstdayofweek ) );
if( firstday>7 || firstday<0 )
throw new HpException(95,"Invalid procedure call");
if( firstday!=0 && dbl>0 )
{
if( firstday>weekday )
tmp = 7 - (firstday - weekday) + 1;
else if( firstday==weekday )
tmp = 1 ;
else
tmp = weekday - firstday + 1;
v = new VInt( (short)tmp );
}
else if(firstday==0 && dbl>=0 )
{
v = new VInt( weekday );
}
else
{
if( firstday==0 )
tmp = weekday - firstday;
else if( firstday>weekday )
tmp = 7 - (firstday - weekday) + 1;
else if( firstday<=weekday )
tmp = weekday - firstday + 1;
if( tmp==0 )
tmp = 7;
v = new VInt( (short)tmp );
}
}
return v;
}
/*------------- Function:WeekDay(date) ----------*/
public static Variant WEEKDAY(Variant exp) throws HpException
{
HCDateTimeStruct tm;
short weekday;
Variant v = null;
int type = exp.getType();
if( type==Variant.V_NULL)
{
v = new VNull();
}
else
{
double dbl = getdt_db( exp) ;
tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
weekday = (short)tm.dt_week;
v = new VInt( weekday);
}
return v;
}
public static short WEEKDAY(boolean exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp==true ? (double)-1:(double)0;
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_week);
}
public static short WEEKDAY(HByte exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)(exp.byteValue()));
return (short)(tm.dt_week);
}
public static short WEEKDAY(short exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_week);
}
public static short WEEKDAY(int exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_week);
}
public static short WEEKDAY(float exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_week);
}
public static short WEEKDAY(double exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(exp);
return (short)(tm.dt_week);
}
public static short WEEKDAY(HCurr exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp.dblValue();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_week);
}
public static short WEEKDAY(HDate exp) throws HpException
{
double dbl = exp.dblValue();
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_week);
}
public static short WEEKDAY(fixedString exp) throws HpException
{
double dbl = getdt_db(new VString(exp.strValue() ) );
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_week);
}
public static short WEEKDAY(String exp) throws HpException
{
double dbl = getdt_db( (Variant)(new VString(exp) ));
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_week);
}
/**
*Hour(date)
*Returns a whole number between 0 and 23, inclusive, representing the hour of
*the day. If time contains Null, Null is returned.
*/
public static Variant HOUR(Variant exp) throws HpException
{
HCDateTimeStruct tm;
Variant v = null;
int type = exp.getType();
if( type==Variant.V_NULL)
{
v = new VNull();
}
else
{
double dbl = getdt_db( exp) ;
tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
v = new VInt( (short)tm.dt_hour );
}
return v;
}
public static short HOUR(boolean exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp==true ? (double)-1:(double)0;
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_hour);
}
public static short HOUR(HByte exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)(exp.byteValue()));
return (short)(tm.dt_hour);
}
public static short HOUR(short exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_hour);
}
public static short HOUR(int exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_hour);
}
public static short HOUR(float exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_hour);
}
public static short HOUR(double exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(exp);
return (short)(tm.dt_hour);
}
public static short HOUR(HCurr exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp.dblValue();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_hour);
}
public static short HOUR(HDate exp) throws HpException
{
double dbl = exp.dblValue();
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_hour);
}
public static short HOUR(fixedString exp) throws HpException
{
double dbl = getdt_db(new VString(exp.strValue() ) );
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_hour);
}
public static short HOUR(String exp) throws HpException
{
double dbl = getdt_db( (Variant)(new VString(exp) ));
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_hour);
}
/**
*Minute(date)
*Returns a whole number between 0 and 59, inclusive, representing the minute of
*the hour.If time contains Null, Null is returned.
*/
public static Variant MINUTE(Variant exp) throws HpException
{
HCDateTimeStruct tm;
Variant v = null;
int type = exp.getType();
if( type==Variant.V_NULL)
{
v = new VNull();
}
else
{
double dbl = getdt_db( exp) ;
tm = new HCDateTimeStruct();
tm.DT_DblToStruc(dbl);
v = new VInt( (short)tm.dt_minute );
}
return v;
}
public static short MINUTE(boolean exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp==true ? (double)-1:(double)0;
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_minute);
}
public static short MINUTE(HByte exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)(exp.byteValue()));
return (short)(tm.dt_minute);
}
public static short MINUTE(short exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_minute);
}
public static short MINUTE(int exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_minute);
}
public static short MINUTE(float exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc((double)exp);
return (short)(tm.dt_minute);
}
public static short MINUTE(double exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
tm.DT_DblToStruc(exp);
return (short)(tm.dt_minute);
}
public static short MINUTE(HCurr exp) throws HpException
{
HCDateTimeStruct tm = new HCDateTimeStruct();
double dbl = exp.dblValue();
tm.DT_DblToStruc(dbl);
return (short)(tm.dt_minute);
}
public static short MINUTE(HDate exp) throws HpException
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?