Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

feat(formula): supplement EPOCHTODATE/TO_DATE/ISDATE formula (#3979)

wpxp1234560656167e7a9f
diff --git a/packages/engine-formula/src/functions/date/epochtodate/__tests__/index.spec.ts b/packages/engine-formula/src/functions/date/epochtodate/__tests__/index.spec.ts
new file mode 100644
index 0000000000..dc7497c6cc
--- /dev/null
+++ b/packages/engine-formula/src/functions/date/epochtodate/__tests__/index.spec.ts
@@ -0,0 +1,142 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_DATE } from '../../function-names';
+import { Epochtodate } from '../index';
+
+describe('Test epochtodate function', () => {
+ const testFunction = new Epochtodate(FUNCTION_NAMES_DATE.EPOCHTODATE);
+
+ describe('Epochtodate', () => {
+ it('value is normal', () => {
+ const timestamp = NumberValueObject.create(1655906710);
+ const result = testFunction.calculate(timestamp);
+ expect(getObjectValue(result)).toBe(44734.58692129629);
+ });
+
+ it('Timestamp value test', () => {
+ const timestamp = NullValueObject.create();
+ const result = testFunction.calculate(timestamp);
+ expect(getObjectValue(result)).toBe(ErrorType.VALUE);
+
+ const timestamp2 = StringValueObject.create('test');
+ const result2 = testFunction.calculate(timestamp2);
+ expect(getObjectValue(result2)).toBe(ErrorType.VALUE);
+
+ const timestamp3 = BooleanValueObject.create(true);
+ const result3 = testFunction.calculate(timestamp3);
+ expect(getObjectValue(result3)).toBe(ErrorType.VALUE);
+
+ const timestamp4 = ErrorValueObject.create(ErrorType.NAME);
+ const result4 = testFunction.calculate(timestamp4);
+ expect(getObjectValue(result4)).toBe(ErrorType.NAME);
+
+ const timestamp5 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ ]),
+ rowCount: 1,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result5 = testFunction.calculate(timestamp5);
+ expect(getObjectValue(result5)).toBe(ErrorType.VALUE);
+
+ const timestamp6 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [-1],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result6 = testFunction.calculate(timestamp6);
+ expect(getObjectValue(result6)).toBe(ErrorType.NUM);
+
+ const timestamp7 = StringValueObject.create('50%');
+ const result7 = testFunction.calculate(timestamp7);
+ expect(getObjectValue(result7)).toBe(ErrorType.VALUE);
+ });
+
+ it('Unit value test', () => {
+ const timestamp = NumberValueObject.create(1655906710);
+ const unit = NumberValueObject.create(2);
+ const result = testFunction.calculate(timestamp, unit);
+ expect(getObjectValue(result)).toBe(25588.165586921295);
+
+ const unit2 = NumberValueObject.create(3);
+ const result2 = testFunction.calculate(timestamp, unit2);
+ expect(getObjectValue(result2)).toBe(25569.019165578702);
+
+ const unit3 = NullValueObject.create();
+ const result3 = testFunction.calculate(timestamp, unit3);
+ expect(getObjectValue(result3)).toBe(ErrorType.NUM);
+
+ const unit4 = StringValueObject.create('test');
+ const result4 = testFunction.calculate(timestamp, unit4);
+ expect(getObjectValue(result4)).toBe(ErrorType.VALUE);
+
+ const unit5 = BooleanValueObject.create(true);
+ const result5 = testFunction.calculate(timestamp, unit5);
+ expect(getObjectValue(result5)).toBe(44734.58692129629);
+
+ const unit6 = ErrorValueObject.create(ErrorType.NAME);
+ const result6 = testFunction.calculate(timestamp, unit6);
+ expect(getObjectValue(result6)).toBe(ErrorType.NAME);
+
+ const unit7 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ ]),
+ rowCount: 1,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result7 = testFunction.calculate(timestamp, unit7);
+ expect(getObjectValue(result7)).toBe(ErrorType.VALUE);
+
+ const unit8 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [-1],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result8 = testFunction.calculate(timestamp, unit8);
+ expect(getObjectValue(result8)).toBe(ErrorType.NUM);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/date/epochtodate/index.ts b/packages/engine-formula/src/functions/date/epochtodate/index.ts
new file mode 100644
index 0000000000..1c1511e9a2
--- /dev/null
+++ b/packages/engine-formula/src/functions/date/epochtodate/index.ts
@@ -0,0 +1,147 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { excelDateTimeSerial } from '../../../basics/date';
+import { ErrorType } from '../../../basics/error-type';
+import { checkVariantsErrorIsStringToNumber } from '../../../engine/utils/check-variant-error';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+
+export class Epochtodate extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 2;
+
+ override needsReferenceObject = true;
+
+ override calculate(timestamp: FunctionVariantType, unit?: FunctionVariantType): BaseValueObject {
+ const _unit = unit ?? NumberValueObject.create(1);
+
+ const { isError, errorObject, timestampIsReferenceObject, timestampObject, unitObject } = this._checkVariants(timestamp, _unit);
+
+ if (isError) {
+ return errorObject as ErrorValueObject;
+ }
+
+ if ((timestampObject as BaseValueObject).isNull() || (timestampObject as BaseValueObject).isBoolean() || (timestampObject as BaseValueObject).isString()) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ if (!timestampIsReferenceObject && (timestampObject as BaseValueObject).isNumber() && (timestampObject as BaseValueObject).getPattern() !== '') {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ let timestampValue = +(timestampObject as BaseValueObject).getValue();
+
+ const { isError: _isError, errorObject: _errorObject, variants } = checkVariantsErrorIsStringToNumber(unitObject as BaseValueObject);
+
+ if (_isError) {
+ return _errorObject as ErrorValueObject;
+ }
+
+ const [_unitObject] = variants as BaseValueObject[];
+
+ const unitValue = Math.floor(+_unitObject.getValue());
+
+ if (timestampValue < 0 || unitValue < 1 || unitValue > 3) {
+ return ErrorValueObject.create(ErrorType.NUM);
+ }
+
+ if (unitValue === 1) {
+ timestampValue = timestampValue * 1000;
+ }
+
+ if (unitValue === 3) {
+ timestampValue = timestampValue / 1000;
+ }
+
+ const date = new Date(Date.UTC(1970, 0, 1, 0, 0, 0, 0) + timestampValue);
+ const dateSerialNumber = excelDateTimeSerial(date);
+
+ return NumberValueObject.create(dateSerialNumber, 'yyyy-MM-dd hh:mm:ss AM/PM');
+ }
+
+ private _checkVariants(timestamp: FunctionVariantType, unit: FunctionVariantType) {
+ const timestampIsReferenceObject = timestamp.isReferenceObject();
+ const unitIsReferenceObject = unit.isReferenceObject();
+
+ let _timestamp = timestamp;
+
+ if (timestampIsReferenceObject) {
+ _timestamp = (timestamp as BaseReferenceObject).toArrayValueObject();
+ }
+
+ if (_timestamp.isArray()) {
+ const rowCount = (_timestamp as ArrayValueObject).getRowCount();
+ const columnCount = (_timestamp as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.VALUE),
+ };
+ }
+
+ _timestamp = (_timestamp as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_timestamp.isError()) {
+ return {
+ isError: true,
+ errorObject: _timestamp as ErrorValueObject,
+ };
+ }
+
+ let _unit = unit;
+
+ if (unitIsReferenceObject) {
+ _unit = (unit as BaseReferenceObject).toArrayValueObject();
+ }
+
+ if (_unit.isArray()) {
+ const rowCount = (_unit as ArrayValueObject).getRowCount();
+ const columnCount = (_unit as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return {
+ isError: true,
+ errorObject: ErrorValueObject.create(ErrorType.VALUE),
+ };
+ }
+
+ _unit = (_unit as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_unit.isError()) {
+ return {
+ isError: true,
+ errorObject: _unit as ErrorValueObject,
+ };
+ }
+
+ return {
+ isError: false,
+ errorObject: null,
+ timestampIsReferenceObject,
+ timestampObject: _timestamp as BaseValueObject,
+ unitIsReferenceObject,
+ unitObject: _unit as BaseValueObject,
+ };
+ }
+}
diff --git a/packages/engine-formula/src/functions/date/function-map.ts b/packages/engine-formula/src/functions/date/function-map.ts
index 633c8d0ead..5dcecb55a9 100644
--- a/packages/engine-formula/src/functions/date/function-map.ts
+++ b/packages/engine-formula/src/functions/date/function-map.ts
@@ -14,7 +14,6 @@
* limitations under the License.
*/
-import { FUNCTION_NAMES_DATE } from './function-names';
import { DateFunction } from './date';
import { Datedif } from './datedif';
import { Datevalue } from './datevalue';
@@ -23,6 +22,8 @@ import { Days } from './days';
import { Days360 } from './days360';
import { Edate } from './edate';
import { Eomonth } from './eomonth';
+import { Epochtodate } from './epochtodate';
+import { FUNCTION_NAMES_DATE } from './function-names';
import { Hour } from './hour';
import { Isoweeknum } from './isoweeknum';
import { Minute } from './minute';
@@ -33,6 +34,7 @@ import { Now } from './now';
import { Second } from './second';
import { Time } from './time';
import { Timevalue } from './timevalue';
+import { ToDate } from './to-date';
import { Today } from './today';
import { Weekday } from './weekday';
import { Weeknum } from './weeknum';
@@ -50,6 +52,7 @@ export const functionDate = [
[Days360, FUNCTION_NAMES_DATE.DAYS360],
[Edate, FUNCTION_NAMES_DATE.EDATE],
[Eomonth, FUNCTION_NAMES_DATE.EOMONTH],
+ [Epochtodate, FUNCTION_NAMES_DATE.EPOCHTODATE],
[Hour, FUNCTION_NAMES_DATE.HOUR],
[Isoweeknum, FUNCTION_NAMES_DATE.ISOWEEKNUM],
[Minute, FUNCTION_NAMES_DATE.MINUTE],
@@ -60,6 +63,7 @@ export const functionDate = [
[Second, FUNCTION_NAMES_DATE.SECOND],
[Time, FUNCTION_NAMES_DATE.TIME],
[Timevalue, FUNCTION_NAMES_DATE.TIMEVALUE],
+ [ToDate, FUNCTION_NAMES_DATE.TO_DATE],
[Today, FUNCTION_NAMES_DATE.TODAY],
[Weekday, FUNCTION_NAMES_DATE.WEEKDAY],
[Weeknum, FUNCTION_NAMES_DATE.WEEKNUM],
diff --git a/packages/engine-formula/src/functions/date/function-names.ts b/packages/engine-formula/src/functions/date/function-names.ts
index 383fe1b1fa..a82a8d9971 100644
--- a/packages/engine-formula/src/functions/date/function-names.ts
+++ b/packages/engine-formula/src/functions/date/function-names.ts
@@ -23,6 +23,7 @@ export enum FUNCTION_NAMES_DATE {
DAYS360 = 'DAYS360',
EDATE = 'EDATE',
EOMONTH = 'EOMONTH',
+ EPOCHTODATE = 'EPOCHTODATE',
HOUR = 'HOUR',
ISOWEEKNUM = 'ISOWEEKNUM',
MINUTE = 'MINUTE',
@@ -33,6 +34,7 @@ export enum FUNCTION_NAMES_DATE {
SECOND = 'SECOND',
TIME = 'TIME',
TIMEVALUE = 'TIMEVALUE',
+ TO_DATE = 'TO_DATE',
TODAY = 'TODAY',
WEEKDAY = 'WEEKDAY',
WEEKNUM = 'WEEKNUM',
diff --git a/packages/engine-formula/src/functions/date/to-date/__tests__/index.spec.ts b/packages/engine-formula/src/functions/date/to-date/__tests__/index.spec.ts
new file mode 100644
index 0000000000..8a00c08bf6
--- /dev/null
+++ b/packages/engine-formula/src/functions/date/to-date/__tests__/index.spec.ts
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_DATE } from '../../function-names';
+import { ToDate } from '../index';
+
+describe('Test toDate function', () => {
+ const testFunction = new ToDate(FUNCTION_NAMES_DATE.TO_DATE);
+
+ describe('ToDate', () => {
+ it('value is normal', () => {
+ const value = NumberValueObject.create(40826.4375);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(40826.4375);
+ });
+
+ it('value is number string', () => {
+ const value = StringValueObject.create('40826.4375');
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe('40826.4375');
+ });
+
+ it('value is normal string', () => {
+ const value = StringValueObject.create('test');
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe('test');
+
+ const value2 = StringValueObject.create('50%');
+ const result2 = testFunction.calculate(value2);
+ expect(getObjectValue(result2)).toBe('50%');
+ });
+
+ it('value is blank cell', () => {
+ const value = NullValueObject.create();
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(0);
+ });
+
+ it('value is boolean', () => {
+ const value = BooleanValueObject.create(true);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(true);
+ });
+
+ it('value is error', () => {
+ const value = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('value is array', () => {
+ const value = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ ]),
+ rowCount: 1,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(value);
+ expect(result.getValue()).toBe(ErrorType.VALUE);
+
+ const value2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [-1],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(value2);
+ expect(result2.getValue()).toBe(-1);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/date/to-date/index.ts b/packages/engine-formula/src/functions/date/to-date/index.ts
new file mode 100644
index 0000000000..f9e253f375
--- /dev/null
+++ b/packages/engine-formula/src/functions/date/to-date/index.ts
@@ -0,0 +1,68 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { BaseReferenceObject, FunctionVariantType } from '../../../engine/reference-object/base-reference-object';
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { ErrorType } from '../../../basics/error-type';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { NumberValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+
+export class ToDate extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override needsReferenceObject = true;
+
+ override calculate(value: FunctionVariantType): BaseValueObject {
+ const isReferenceObject = value.isReferenceObject();
+
+ let _value = value;
+
+ if (isReferenceObject) {
+ _value = (value as BaseReferenceObject).toArrayValueObject();
+ }
+
+ if (_value.isArray()) {
+ const rowCount = (_value as ArrayValueObject).getRowCount();
+ const columnCount = (_value as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ _value = (_value as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (
+ (_value as BaseValueObject).isError() ||
+ (_value as BaseValueObject).isNull() ||
+ (_value as BaseValueObject).isBoolean() ||
+ (_value as BaseValueObject).isString()
+ ) {
+ return _value as BaseValueObject;
+ }
+
+ if (!isReferenceObject && (_value as BaseValueObject).isNumber() && _value.getPattern() !== '') {
+ return _value as BaseValueObject;
+ }
+
+ const val = +(_value as BaseValueObject).getValue();
+
+ return NumberValueObject.create(val, 'yyyy-MM-dd hh:mm:ss AM/PM');
+ }
+}
diff --git a/packages/engine-formula/src/functions/information/function-map.ts b/packages/engine-formula/src/functions/information/function-map.ts
index c08e8b22f8..eb821887bd 100644
--- a/packages/engine-formula/src/functions/information/function-map.ts
+++ b/packages/engine-formula/src/functions/information/function-map.ts
@@ -18,6 +18,7 @@ import { Cell } from './cell';
import { ErrorType } from './error-type';
import { FUNCTION_NAMES_INFORMATION } from './function-names';
import { Isblank } from './isblank';
+import { Isdate } from './isdate';
import { Iserr } from './iserr';
import { Iserror } from './iserror';
import { Iseven } from './iseven/iseven';
@@ -39,6 +40,7 @@ export const functionInformation = [
[Cell, FUNCTION_NAMES_INFORMATION.CELL],
[ErrorType, FUNCTION_NAMES_INFORMATION.ERROR_TYPE],
[Isblank, FUNCTION_NAMES_INFORMATION.ISBLANK],
+ [Isdate, FUNCTION_NAMES_INFORMATION.ISDATE],
[Iserr, FUNCTION_NAMES_INFORMATION.ISERR],
[Iserror, FUNCTION_NAMES_INFORMATION.ISERROR],
[Iseven, FUNCTION_NAMES_INFORMATION.ISEVEN],
diff --git a/packages/engine-formula/src/functions/information/function-names.ts b/packages/engine-formula/src/functions/information/function-names.ts
index 6d68d081c7..b165996436 100644
--- a/packages/engine-formula/src/functions/information/function-names.ts
+++ b/packages/engine-formula/src/functions/information/function-names.ts
@@ -19,6 +19,7 @@ export enum FUNCTION_NAMES_INFORMATION {
ERROR_TYPE = 'ERROR.TYPE',
INFO = 'INFO',
ISBLANK = 'ISBLANK',
+ ISDATE = 'ISDATE',
ISERR = 'ISERR',
ISERROR = 'ISERROR',
ISEVEN = 'ISEVEN',
diff --git a/packages/engine-formula/src/functions/information/isdate/__tests__/index.spec.ts b/packages/engine-formula/src/functions/information/isdate/__tests__/index.spec.ts
new file mode 100644
index 0000000000..a94e5a18c2
--- /dev/null
+++ b/packages/engine-formula/src/functions/information/isdate/__tests__/index.spec.ts
@@ -0,0 +1,105 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import { describe, expect, it } from 'vitest';
+
+import { ErrorType } from '../../../../basics/error-type';
+import { ArrayValueObject, transformToValueObject } from '../../../../engine/value-object/array-value-object';
+import { ErrorValueObject } from '../../../../engine/value-object/base-value-object';
+import { BooleanValueObject, NullValueObject, NumberValueObject, StringValueObject } from '../../../../engine/value-object/primitive-object';
+import { getObjectValue } from '../../../__tests__/create-function-test-bed';
+import { FUNCTION_NAMES_INFORMATION } from '../../function-names';
+import { Isdate } from '../index';
+
+describe('Test isdate function', () => {
+ const testFunction = new Isdate(FUNCTION_NAMES_INFORMATION.ISDATE);
+
+ describe('Isdate', () => {
+ it('value is normal', () => {
+ const value = StringValueObject.create('2012-2-2');
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(true);
+ });
+
+ it('value is number', () => {
+ const value = NumberValueObject.create(40826.4375);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+
+ const value2 = NumberValueObject.create(40826.4375, 'yyyy-mm-dd hh:mm:ss');
+ const result2 = testFunction.calculate(value2);
+ expect(getObjectValue(result2)).toBe(true);
+ });
+
+ it('value is normal string', () => {
+ const value = StringValueObject.create('test');
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+
+ const value2 = StringValueObject.create('50%');
+ const result2 = testFunction.calculate(value2);
+ expect(getObjectValue(result2)).toBe(false);
+ });
+
+ it('value is blank cell', () => {
+ const value = NullValueObject.create();
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+ });
+
+ it('value is boolean', () => {
+ const value = BooleanValueObject.create(true);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(false);
+ });
+
+ it('value is error', () => {
+ const value = ErrorValueObject.create(ErrorType.NAME);
+ const result = testFunction.calculate(value);
+ expect(getObjectValue(result)).toBe(ErrorType.NAME);
+ });
+
+ it('value is array', () => {
+ const value = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [1, 2],
+ ]),
+ rowCount: 1,
+ columnCount: 2,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result = testFunction.calculate(value);
+ expect(result.getValue()).toBe(ErrorType.VALUE);
+
+ const value2 = ArrayValueObject.create({
+ calculateValueList: transformToValueObject([
+ [-1],
+ ]),
+ rowCount: 1,
+ columnCount: 1,
+ unitId: '',
+ sheetId: '',
+ row: 0,
+ column: 0,
+ });
+ const result2 = testFunction.calculate(value2);
+ expect(result2.getValue()).toBe(false);
+ });
+ });
+});
diff --git a/packages/engine-formula/src/functions/information/isdate/index.ts b/packages/engine-formula/src/functions/information/isdate/index.ts
new file mode 100644
index 0000000000..9617fc69e3
--- /dev/null
+++ b/packages/engine-formula/src/functions/information/isdate/index.ts
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2023-present DreamNum Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import type { ArrayValueObject } from '../../../engine/value-object/array-value-object';
+import { isDate, parseFormattedDate, parseFormattedTime } from '../../../basics/date';
+import { ErrorType } from '../../../basics/error-type';
+import { type BaseValueObject, ErrorValueObject } from '../../../engine/value-object/base-value-object';
+import { BooleanValueObject } from '../../../engine/value-object/primitive-object';
+import { BaseFunction } from '../../base-function';
+
+export class Isdate extends BaseFunction {
+ override minParams = 1;
+
+ override maxParams = 1;
+
+ override calculate(value: BaseValueObject): BaseValueObject {
+ let _value = value;
+
+ if (_value.isArray()) {
+ const rowCount = (_value as ArrayValueObject).getRowCount();
+ const columnCount = (_value as ArrayValueObject).getColumnCount();
+
+ if (rowCount > 1 || columnCount > 1) {
+ return ErrorValueObject.create(ErrorType.VALUE);
+ }
+
+ _value = (_value as ArrayValueObject).get(0, 0) as BaseValueObject;
+ }
+
+ if (_value.isError()) {
+ return _value;
+ }
+
+ if (_value.isNumber() && _value.getPattern() !== '') {
+ return BooleanValueObject.create(isDate(_value.getPattern()));
+ }
+
+ if (_value.isString() && (parseFormattedDate(`${_value.getValue()}`) || parseFormattedTime(`${_value.getValue()}`))) {
+ return BooleanValueObject.create(true);
+ }
+
+ return BooleanValueObject.create(false);
+ }
+}
diff --git a/packages/sheets-formula-ui/src/locale/function-list/date/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/date/en-US.ts
index afc6fe15e2..4fa027a887 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/date/en-US.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/date/en-US.ts
@@ -128,6 +128,20 @@ export default {
months: { name: 'months', detail: 'The number of months before or after start_date.' },
},
},
+ EPOCHTODATE: {
+ description: 'Converts a Unix epoch timestamp in seconds, milliseconds, or microseconds to a datetime in Universal Time Coordinated (UTC).',
+ abstract: 'Converts a Unix epoch timestamp in seconds, milliseconds, or microseconds to a datetime in Universal Time Coordinated (UTC).',
+ links: [
+ {
+ title: 'Instruction',
+ url: 'https://support.google.com/docs/answer/13193461?hl=zh-Hans&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ timestamp: { name: 'timestamp', detail: 'A Unix epoch timestamp, in seconds, milliseconds, or microseconds.' },
+ unit: { name: 'unit', detail: 'The unit of time in which the timestamp is expressed. 1 by default: \n1 indicates the time unit is seconds. \n2 indicates the time unit is milliseconds.\n3 indicates the time unit is microseconds.' },
+ },
+ },
HOUR: {
description: 'Converts a serial number to an hour',
abstract: 'Converts a serial number to an hour',
@@ -264,6 +278,19 @@ export default {
timeText: { name: 'time_text', detail: 'A text string that represents a time in any one of the Microsoft Excel time formats; for example, "6:45 PM" and "18:45" text strings within quotation marks that represent time.' },
},
},
+ TO_DATE: {
+ description: 'Converts a provided number to a date.',
+ abstract: 'Converts a provided number to a date.',
+ links: [
+ {
+ title: 'Instruction',
+ url: 'https://support.google.com/docs/answer/3094239?hl=en&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: 'value', detail: 'The argument or reference to a cell to be converted to a date.' },
+ },
+ },
TODAY: {
description: 'Returns the serial number of today\'s date',
abstract: 'Returns the serial number of today\'s date',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/date/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/date/ja-JP.ts
index af1aa1f55f..4c924fe2a9 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/date/ja-JP.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/date/ja-JP.ts
@@ -128,6 +128,20 @@ export default {
months: { name: '月', detail: '開始日から起算した月数を指定します。' },
},
},
+ EPOCHTODATE: {
+ description: 'Unix エポック タイムスタンプ(秒、ミリ秒、またはマイクロ秒)を協定世界時(UTC)の日時に変換します。',
+ abstract: 'Unix エポック タイムスタンプ(秒、ミリ秒、またはマイクロ秒)を協定世界時(UTC)の日時に変換します。',
+ links: [
+ {
+ title: '指導',
+ url: 'https://support.google.com/docs/answer/13193461?hl=ja&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ timestamp: { name: 'タイムスタンプ', detail: 'Unix エポック タイムスタンプ(秒、ミリ秒、またはマイクロ秒)。' },
+ unit: { name: '時間の単位', detail: 'タイムスタンプを表示する時間の単位。デフォルト値は 1: \n1 は時間単位が秒であることを示します。\n2 は時間単位がミリ秒であることを示します。\n3 は時間単位がマイクロ秒であることを示します。' },
+ },
+ },
HOUR: {
description: 'シリアル値を時刻に変換します。',
abstract: 'シリアル値を時刻に変換します。',
@@ -264,6 +278,19 @@ export default {
timeText: { name: '時刻文字列', detail: 'Microsoft Excel のいずれかの時刻形式で時刻を表すテキスト文字列。たとえば、"6:45 PM" と "18:45" のテキスト文字列は、時間を表す引用符で囲みます。' },
},
},
+ TO_DATE: {
+ description: '指定された数値を日付に変換します。',
+ abstract: '指定された数値を日付に変換します。',
+ links: [
+ {
+ title: '指導',
+ url: 'https://support.google.com/docs/answer/3094239?hl=ja&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '値', detail: '日付に変換する引数またはセルへの参照です。' },
+ },
+ },
TODAY: {
description: '現在の日付に対応するシリアル値を返します。',
abstract: '現在の日付に対応するシリアル値を返します。',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/date/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/date/vi-VN.ts
index 99a513ec78..8f002c72a8 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/date/vi-VN.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/date/vi-VN.ts
@@ -155,6 +155,20 @@ export default {
},
},
},
+ EPOCHTODATE: {
+ description: 'Chuyển đổi dấu thời gian bắt đầu của hệ thống Unix ở dạng giây, mili giây hoặc micrô giây thành dạng ngày giờ theo Giờ phối hợp quốc tế (UTC).',
+ abstract: 'Chuyển đổi dấu thời gian bắt đầu của hệ thống Unix ở dạng giây, mili giây hoặc micrô giây thành dạng ngày giờ theo Giờ phối hợp quốc tế (UTC).',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.google.com/docs/answer/13193461?hl=vi&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ timestamp: { name: 'dấu thời gian', detail: 'Dấu thời gian bắt đầu của hệ thống Unix ở dạng giây, mili giây hoặc micrô giây.' },
+ unit: { name: 'đơn vị thời gian', detail: 'Đơn vị thời gian mà dấu thời gian thể hiện. 1 theo mặc định: \n1 cho biết đơn vị thời gian là giây. \n2 cho biết đơn vị thời gian là mili giây.\n3 cho biết đơn vị thời gian là micrô giây.' },
+ },
+ },
HOUR: {
description: 'Chuyển đổi số sê-ri thành giờ',
abstract: 'Chuyển đổi số sê-ri thành giờ',
@@ -306,6 +320,19 @@ export default {
},
},
},
+ TO_DATE: {
+ description: 'Chuyển đổi một số cho sẵn thành giá trị ngày (theo lịch).',
+ abstract: 'Chuyển đổi một số cho sẵn thành giá trị ngày (theo lịch).',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.google.com/docs/answer/3094239?hl=vi&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: 'giá trị', detail: 'Đối số hoặc tham chiếu đến một ô sẽ được chuyển đổi thành ngày tháng.' },
+ },
+ },
TODAY: {
description: 'Trả về ngày hiện tại. Hàm này rất hữu ích khi cần sử dụng ngày hiện tại trong các công thức hoặc để tính toán khoảng thời gian liên quan đến ngày hiện tại.',
abstract: 'Trả về ngày hiện tại',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/date/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/date/zh-CN.ts
index b415acd4f0..b68aacee74 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/date/zh-CN.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/date/zh-CN.ts
@@ -128,6 +128,20 @@ export default {
months: { name: '月份数', detail: '开始日期之前或之后的月份数。' },
},
},
+ EPOCHTODATE: {
+ description: '将 Unix 纪元时间戳(以秒、毫秒或微秒为单位)转换为世界协调时间 (UTC) 的日期时间',
+ abstract: '将 Unix 纪元时间戳(以秒、毫秒或微秒为单位)转换为世界协调时间 (UTC) 的日期时间',
+ links: [
+ {
+ title: '教学',
+ url: 'https://support.google.com/docs/answer/13193461?hl=zh-Hans&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ timestamp: { name: '时间戳', detail: 'Unix 纪元时间戳(以秒、毫秒或微秒为单位)。' },
+ unit: { name: '时间单位', detail: '表示时间戳的时间单位。默认情况为 1: \n1 表示时间单位是秒。\n2 表示时间单位是毫秒。\n3 表示时间单位是微秒。' },
+ },
+ },
HOUR: {
description: '将序列号转换为小时',
abstract: '将序列号转换为小时',
@@ -264,6 +278,19 @@ export default {
timeText: { name: '时间文本', detail: '一个文本字符串,代表以任一时间格式表示的时间(例如,代表时间的具有引号的文本字符串 "6:45 PM" 和 "18:45")。' },
},
},
+ TO_DATE: {
+ description: '将提供的数字转换为日期',
+ abstract: '将提供的数字转换为日期',
+ links: [
+ {
+ title: '教学',
+ url: 'https://support.google.com/docs/answer/3094239?hl=zh-Hans&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '值', detail: '要转换为日期的参数或其单元格引用。' },
+ },
+ },
TODAY: {
description: '返回今天日期的序列号',
abstract: '返回今天日期的序列号',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/date/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/date/zh-TW.ts
index ed209cef38..1b1f67ec08 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/date/zh-TW.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/date/zh-TW.ts
@@ -128,6 +128,20 @@ export default {
months: { name: '月份數', detail: '開始日期之前或之後的月份數。' },
},
},
+ EPOCHTODATE: {
+ description: '將 Unix Epoch 紀元時間戳記 (以秒、毫秒或微秒為單位) 轉換為世界標準時間 (UTC) 的日期時間格式',
+ abstract: '將 Unix Epoch 紀元時間戳記 (以秒、毫秒或微秒為單位) 轉換為世界標準時間 (UTC) 的日期時間格式',
+ links: [
+ {
+ title: '教導',
+ url: 'https://support.google.com/docs/answer/13193461?hl=zh-Hant&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ timestamp: { name: '時間戳記', detail: '以秒、毫秒或微秒為單位的 Unix Epoch 紀元時間戳記。' },
+ unit: { name: '時間單位', detail: '時間戳記的表示單位。預設值是 1: \n1 表示以秒為單位。\n2 表示以毫秒為單位。\n3 表示以微秒為單位。' },
+ },
+ },
HOUR: {
description: '將序號轉換為小時',
abstract: '將序號轉換為小時',
@@ -264,6 +278,19 @@ export default {
timeText: { name: '時間文字', detail: '以任何一種時間格式表示的文字字串;例如,"6:45 PM" 和 "18:45",引號中的文字字串表示時間。' },
},
},
+ TO_DATE: {
+ description: '將指定數字轉換成日期',
+ abstract: '將指定數字轉換成日期',
+ links: [
+ {
+ title: '教導',
+ url: 'https://support.google.com/docs/answer/3094239?hl=zh-Hant&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '值', detail: '要轉換成日期的引數或儲存格參照。' },
+ },
+ },
TODAY: {
description: '傳回今天日期的序號',
abstract: '傳回今天日期的序號',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts b/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts
index 87873366ea..41fa6897c3 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/en-US.ts
@@ -69,6 +69,19 @@ export default {
value: { name: 'value', detail: 'The value that you want tested. The value argument can be a blank (empty cell), error, logical value, text, number, or reference value, or a name referring to any of these.' },
},
},
+ ISDATE: {
+ description: 'Returns whether a value is a date.',
+ abstract: 'Returns whether a value is a date.',
+ links: [
+ {
+ title: 'Instruction',
+ url: 'https://support.google.com/docs/answer/9061381?hl=en&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: 'value', detail: 'The value to be verified as a date.' },
+ },
+ },
ISERR: {
description: 'Returns TRUE if the value is any error value except #N/A',
abstract: 'Returns TRUE if the value is any error value except #N/A',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts b/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts
index aeda77dcde..9616fafa7a 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/ja-JP.ts
@@ -69,6 +69,19 @@ export default {
value: { name: '値', detail: 'テストする値を指定します。テストの対象引数には、空白セル、エラー、論理値、文字列、数値、参照値、または対象となるデータを参照する名前を指定することができます。' },
},
},
+ ISDATE: {
+ description: 'は、値が日付かどうかを返します',
+ abstract: 'は、値が日付かどうかを返します',
+ links: [
+ {
+ title: '指導',
+ url: 'https://support.google.com/docs/answer/9061381?hl=ja&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '値', detail: '日付であるかを検証する値です。' },
+ },
+ },
ISERR: {
description: '対象が #N/A 以外のエラー値のときに TRUE を返します。',
abstract: '対象が #N/A 以外のエラー値のときに TRUE を返します。',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts b/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts
index 974d9a5813..4279357a5d 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/vi-VN.ts
@@ -55,6 +55,19 @@ export default {
value: { name: 'Giá trị', detail: 'Giá trị mà bạn muốn kiểm tra. Đối số giá trị có thể là trống (ô trống), lỗi, giá trị lô-gic, văn bản, số, giá trị tham chiếu hoặc tên tham chiếu tới bất kỳ giá trị nào trong những giá trị này.' },
},
},
+ ISDATE: {
+ description: 'xác định xem một giá trị có phải là ngày không.',
+ abstract: 'xác định xem một giá trị có phải là ngày không.',
+ links: [
+ {
+ title: 'Hướng dẫn',
+ url: 'https://support.google.com/docs/answer/9061381?hl=vi&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: 'Giá trị', detail: 'Giá trị cần xác minh có phải là một ngày hay không.' },
+ },
+ },
ISERR: {
description: 'Trả về TRUE nếu giá trị là bất kỳ giá trị lỗi nào ngoại trừ #N/A',
abstract: 'Trả về TRUE nếu giá trị là bất kỳ giá trị lỗi nào ngoại trừ #N/A',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts b/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts
index d7cc98dd63..709baa582c 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/zh-CN.ts
@@ -69,6 +69,19 @@ export default {
value: { name: '值', detail: '指的是要测试的值。参数值可以是空白(空单元格)、错误值、逻辑值、文本、数字、引用值,或者引用要测试的以上任意值的名称。' },
},
},
+ ISDATE: {
+ description: '返回某个值是否为日期',
+ abstract: '返回某个值是否为日期',
+ links: [
+ {
+ title: '教学',
+ url: 'https://support.google.com/docs/answer/9061381?hl=zh-Hans&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '值', detail: '要验证其是否为日期的值。' },
+ },
+ },
ISERR: {
description: '如果值为除 #N/A 以外的任何错误值,则返回 TRUE',
abstract: '如果值为除 #N/A 以外的任何错误值,则返回 TRUE',
diff --git a/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts b/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts
index f47c4e787a..c09671a798 100644
--- a/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts
+++ b/packages/sheets-formula-ui/src/locale/function-list/information/zh-TW.ts
@@ -69,6 +69,19 @@ export default {
value: { name: '值', detail: '指的是要測試的值。參數值可以是空白(空白儲存格)、錯誤值、邏輯值、文字、數字、參考值,或引用要測試的以上任意值的名稱。' },
},
},
+ ISDATE: {
+ description: '針對特定值是否可轉換為日期傳回結果',
+ abstract: '針對特定值是否可轉換為日期傳回結果',
+ links: [
+ {
+ title: '教導',
+ url: 'https://support.google.com/docs/answer/9061381?hl=zh-Hant&sjid=2155433538747546473-AP',
+ },
+ ],
+ functionParameter: {
+ value: { name: '值', detail: '要驗證是否為日期的值。' },
+ },
+ },
ISERR: {
description: '如果值為 #N/A 以外的任何錯誤值,則傳回 TRUE',
abstract: '如果值為 #N/A 以外的任何錯誤值,則傳回 TRUE',
diff --git a/packages/sheets-formula/src/services/function-list/date.ts b/packages/sheets-formula/src/services/function-list/date.ts
index e62f5ee88a..5939f8b64a 100644
--- a/packages/sheets-formula/src/services/function-list/date.ts
+++ b/packages/sheets-formula/src/services/function-list/date.ts
@@ -200,6 +200,28 @@ export const FUNCTION_LIST_DATE: IFunctionInfo[] = [
},
],
},
+ {
+ functionName: FUNCTION_NAMES_DATE.EPOCHTODATE,
+ functionType: FunctionType.Date,
+ description: 'formula.functionList.EPOCHTODATE.description',
+ abstract: 'formula.functionList.EPOCHTODATE.abstract',
+ functionParameter: [
+ {
+ name: 'formula.functionList.EPOCHTODATE.functionParameter.timestamp.name',
+ detail: 'formula.functionList.EPOCHTODATE.functionParameter.timestamp.detail',
+ example: '1655906710',
+ require: 1,
+ repeat: 0,
+ },
+ {
+ name: 'formula.functionList.EPOCHTODATE.functionParameter.unit.name',
+ detail: 'formula.functionList.EPOCHTODATE.functionParameter.unit.detail',
+ example: '1',
+ require: 0,
+ repeat: 0,
+ },
+ ],
+ },
{
functionName: FUNCTION_NAMES_DATE.HOUR,
functionType: FunctionType.Date,
@@ -392,6 +414,21 @@ export const FUNCTION_LIST_DATE: IFunctionInfo[] = [
},
],
},
+ {
+ functionName: FUNCTION_NAMES_DATE.TO_DATE,
+ functionType: FunctionType.Date,
+ description: 'formula.functionList.TO_DATE.description',
+ abstract: 'formula.functionList.TO_DATE.abstract',
+ functionParameter: [
+ {
+ name: 'formula.functionList.TO_DATE.functionParameter.value.name',
+ detail: 'formula.functionList.TO_DATE.functionParameter.value.detail',
+ example: '40826.4375',
+ require: 1,
+ repeat: 0,
+ },
+ ],
+ },
{
functionName: FUNCTION_NAMES_DATE.TODAY,
functionType: FunctionType.Date,
diff --git a/packages/sheets-formula/src/services/function-list/information.ts b/packages/sheets-formula/src/services/function-list/information.ts
index d465fa4511..2919559d66 100644
--- a/packages/sheets-formula/src/services/function-list/information.ts
+++ b/packages/sheets-formula/src/services/function-list/information.ts
@@ -91,6 +91,21 @@ export const FUNCTION_LIST_INFORMATION: IFunctionInfo[] = [
},
],
},
+ {
+ functionName: FUNCTION_NAMES_INFORMATION.ISDATE,
+ functionType: FunctionType.Information,
+ description: 'formula.functionList.ISDATE.description',
+ abstract: 'formula.functionList.ISDATE.abstract',
+ functionParameter: [
+ {
+ name: 'formula.functionList.ISDATE.functionParameter.value.name',
+ detail: 'formula.functionList.ISDATE.functionParameter.value.detail',
+ example: 'A1',
+ require: 1,
+ repeat: 0,
+ },
+ ],
+ },
{
functionName: FUNCTION_NAMES_INFORMATION.ISERR,
functionType: FunctionType.Information,