263 lines
5.8 KiB
Markdown
263 lines
5.8 KiB
Markdown
# 基础函数 / 日期时间
|
||
|
||
## `endOfTheHalfYear(end_t)`
|
||
|
||
声明:function
|
||
|
||
返回Endt所在半年的截止日期(半年的最后一天)
|
||
|
||
<!-- tags: 返回 获取 -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | --------- | ---- |
|
||
| `end_t` | tdatetime | 日期 |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
end_t := 40540; // 40540表示2010年12月28日
|
||
return endOfTheHalfYear (end_t);
|
||
// 输出:40543 ;40543表示2010年12月31号
|
||
```
|
||
|
||
## `endOfTheQuarter(end_t)`
|
||
|
||
声明:function
|
||
|
||
返回Endt所在季度的截止日期(季度的最后一天)
|
||
|
||
<!-- tags: 返回 获取 -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | --------- | ---- |
|
||
| `end_t` | tdatetime | 日期 |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
end_t := 40540; // 40540表示2010年12月28日
|
||
return endOfTheQuarter (end_t);
|
||
// 输出:40543 ;40543表示2010年12月31号
|
||
```
|
||
|
||
## `excelDateToInt(r_date)`
|
||
|
||
声明:function
|
||
|
||
将日期型报告期转化成整数型报告期
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| -------- | --------- | ------------ |
|
||
| `r_date` | tdatetime | 日期型报告期 |
|
||
|
||
返回:integer
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
r_date := 20101231;
|
||
return excelDateToInt(r_date);
|
||
// 输出:20101231
|
||
```
|
||
|
||
## `excelIntToDate(r_date)`
|
||
|
||
声明:function
|
||
|
||
将报告期类型日期转化成实数型
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| -------- | ------- | ------------------ |
|
||
| `r_date` | integer | 整型类的报告期日期 |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
// 报告期为2010年年报
|
||
r_date := 20101231;
|
||
return excelIntToDate(r_date);
|
||
// 输出:40543
|
||
```
|
||
|
||
## `excelRDate(r_date)`
|
||
|
||
声明:function
|
||
|
||
将整数报告期转换成Excel的字符串日期类型
|
||
|
||
<!-- tags: 转换 编码 -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| -------- | ------- | -------------------------- |
|
||
| `r_date` | integer | 报告期,一般用整型日期表示 |
|
||
|
||
返回:string
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
r_date := 20101231;
|
||
return excelRDate(r_date);
|
||
// 输出:2010-12-31
|
||
```
|
||
|
||
## `formatStrToDateTime2(s, format_str)`
|
||
|
||
声明:function
|
||
|
||
格式化字符串->日期时间(包含毫秒)
|
||
|
||
<!-- tags: 格式化 format -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------------ | ------ | ---------------------- |
|
||
| `s` | string | 字符串类型,时间字符串 |
|
||
| `format_str` | string | 字符串类型,格式字符串 |
|
||
|
||
返回:datetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
// 字符串2021-8-12 10:31:24:199 转换为日期时间格式(包含毫秒)
|
||
s := "2021.01.04T23:00:00.000";
|
||
format_str := "yyyy.mm.ddThh:nn:ss.zzz";
|
||
return formatStrToDateTime2(s, format_str); // 输出:44200.9583333333
|
||
```
|
||
|
||
## `incHalfYear(a_value, number)`
|
||
|
||
声明:function
|
||
|
||
求Avalue的日期开始往后推移Number个半年的日期
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| --------- | --------- | -------------------------------- |
|
||
| `a_value` | tdatetime | 实数表示的日期 |
|
||
| `number` | integer | 向后推移的整数,负数表示向前推移 |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
avalue := 40179; // 40179表示2010年1月1号
|
||
number := 2;
|
||
return incHalfYear(a_value, number);
|
||
// 输出:40544 ;40544表示2011年1月1号
|
||
```
|
||
|
||
## `incQuarter(avalue, number)`
|
||
|
||
声明:function
|
||
|
||
求Avalue的日期开始往后推移Number个季度的日期
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| -------- | --------- | ---------------------------------- |
|
||
| `avalue` | tdatetime | 实数表示的日期 |
|
||
| `number` | integer | 向后推移的整数。负数表示向前推移。 |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
avalue := 40179; // 40179表示2010年1月1号
|
||
number := 2;
|
||
return incQuarter(a_value, number);
|
||
// 输出:40360 ;40360表示2010年7月1号
|
||
```
|
||
|
||
## `startOfTheHalfYear(end_t)`
|
||
|
||
声明:function
|
||
|
||
返回Endt所在半年的开始日期(半年的第一天)
|
||
|
||
<!-- tags: 返回 获取 -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | --------- | ---- |
|
||
| `end_t` | tdatetime | 日期 |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
end_t := 40599; // 40559表示2011年1月16号
|
||
return startOfTheHalfYear(end_t);
|
||
// 输出:40544 ;40544表示2011年1月1号
|
||
```
|
||
|
||
## `startOfTheQuarter(end_t)`
|
||
|
||
声明:function
|
||
|
||
返回Endt所在季度的开始日期(季度的第一天)
|
||
|
||
<!-- tags: 返回 获取 -->
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------- | --------- | ---- |
|
||
| `end_t` | tdatetime | 日期 |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
end_t := 40540; // 40540表示2010年12月28日
|
||
return startOfTheQuarter (end_t);
|
||
// 输出:40452 ;40452表示2010年10月1号
|
||
```
|
||
|
||
## `strToDateExt(s, str_format)`
|
||
|
||
声明:function
|
||
|
||
将字符串类型的日期按照不同的格式转换成实数型的日期
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ------------ | ------- | ------------------------------------------ |
|
||
| `s` | string | 字符串类型的日期,包含3中形式,见下表。 |
|
||
| `str_format` | integer | 标准化的日期格式,对应的S分别用0、1、2表示 |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
s := '16/1/2011';
|
||
str_format := 0;
|
||
return strToDateExt(s, str_format);
|
||
// 输出:40559
|
||
```
|
||
|
||
## `strtodatetime2(s)`
|
||
|
||
声明:function
|
||
|
||
字符串->日期时间(包含毫秒)
|
||
|
||
| 参数 | 类型 | 说明 |
|
||
| ---- | ------ | -------------------------------------------------------------------------------------------------------------- |
|
||
| `s` | string | S的格式必须为:yyyy-m-d h:m:s:z 其中日期和时间需要用空格隔开,时间分隔必须用: 如"2021-8-12 10:31:24:199" |
|
||
|
||
返回:tdatetime
|
||
|
||
### 示例
|
||
|
||
```tsl
|
||
// 字符串2021-8-12 10:31:24:199 转换为日期时间格式(包含毫秒)
|
||
s := "2021-8-12 10:31:24:199";
|
||
return strtodatetime2(s); // 输出:44420.4384745255
|
||
```
|