Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time and DateTime types and duration #229

Closed
wojciechczerniak opened this issue Mar 1, 2020 · 8 comments
Closed

Time and DateTime types and duration #229

wojciechczerniak opened this issue Mar 1, 2020 · 8 comments
Assignees
Labels
Feature Something we can add later on without introducing a breaking change
Milestone

Comments

@wojciechczerniak
Copy link
Contributor

Description

While removing #118 moment.js dep, we've removed the support for DateTime and Time data types. We have to bring back the support for those data types.

Time [1] is defined as "Time is a subtype of Number. Time is represented as a fraction of a day."
DateTime [2] is defined as "DateTime is a subtype of Number. It is a Date plus Time."

Is returned by some function: NOW, WORKDAY, VALUE.

Time is parsed from strings: "HH:MM:SS AM/PM", "HH:MM AM/PM", "HH:MM:SS", "HH:MM"

Duration is often a result of arithmetic operators between time values.

Evaluators shall support time values in at least the HH:MM and HH:MM:SS formats, where HH is a 1-2 digit value from 0 to 23, MM is a one- or two-digit value from 0 to 59, and SS is a one- or two-digit value from 0 to 59. The hour may be one or two digits when it is less than 10. VALUE converts time values into Numbers ranging from 0 to 1, which is percentage of day that has elapsed by that time. Thus, VALUE("2:00") is the same as 2/24. Evaluators should accept times with fractional seconds as well when expressed in the form HH:MM:SS.ssss...

Links

[1] https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__1017886_715980110
[2] https://docs.oasis-open.org/office/OpenDocument/v1.3/csprd02/part4-formula/OpenDocument-v1.3-csprd02-part4-formula.html#__RefHeading__74713_1363921367

@wojciechczerniak wojciechczerniak added Feature Something we can add later on without introducing a breaking change Syntax labels Mar 1, 2020
@wojciechczerniak wojciechczerniak added this to the March 2020 milestone Mar 1, 2020
@wojciechczerniak wojciechczerniak mentioned this issue Mar 1, 2020
89 tasks
@izulin izulin assigned izulin and unassigned bardek8 Mar 1, 2020
@izulin izulin mentioned this issue Mar 27, 2020
7 tasks
@izulin
Copy link
Collaborator

izulin commented Apr 7, 2020

closed? #276

@wojciechczerniak
Copy link
Contributor Author

Unfortunately, the PR was merged before I've managed to check it. I don't know where we are with this and I don't see tests for some use cases so we will have to wait for @aninde.

It should be possible to recreate all formats shown here: https://support.office.com/en-us/article/TEXT-function-20D5AC4D-7B94-49FD-BB38-93D29371225C with stringifyDateTime and a library like moment.js ?

Time

obraz

Date

obraz

What about the other way around? When do we use parseDateTime callback? Can we provide all the mentioned formats in the dateFormats and have them correctly recognized? Then parsed with moment.js or date-fns packages?


BTW I think I've found an issue with the TEXT function. It is in DatePlugin, while it can format a lot more than date or time.

Fractions

obraz

Percentages

obraz

Maybe the stringifyDateTime and parseDateTime are not the right answer? 🤔 Maybe we need something a lot more generic? Parse any string or return it as is?

@izulin
Copy link
Collaborator

izulin commented Apr 8, 2020

@wojciechczerniak
I think that roughly whatever was requested by this request was covered in #276 (to be verified, but see tests here: https://github.com/handsontable/hyperformula/blob/develop/test/date.spec.ts )
Other issues that you mention (which are certainly interesting and non-trivial) here are outside of scope of this issue, and deserve their proper separate issues.

@izulin
Copy link
Collaborator

izulin commented Apr 8, 2020

and tests here: https://github.com/handsontable/hyperformula/blob/develop/test/interpreter/function-text.spec.ts

@wojciechczerniak
Copy link
Contributor Author

I have created an issue for things that were out of scope

You can find it here: #314. I agree we should focus on Time, DateTime and Duration here.

Not all format options are supported

For AM/PM we've got A/P but we should support AM/PM as well.

XL:
obraz

We're missing fraction of seconds

ODFF:

Evaluators shall support time values in at least the HH:MM and HH:MM:SS formats, where HH is a 1-2 digit value from 0 to 23, MM is a one- or two-digit value from 0 to 59, and SS is a one- or two-digit value from 0 to 59. The hour may be one or two digits when it is less than 10. VALUE converts time values into Numbers ranging from 0 to 1, which is percentage of day that has elapsed by that time. Thus, VALUE("2:00") is the same as 2/24. Evaluators should accept times with fractional seconds as well when expressed in the form HH:MM:SS.ssss...

Libre:
obraz

XL:
obraz

We're missing the duration format (square brackets [ ])

Libre:
obraz

XL:
obraz

Note that the default format contains the brackets, hours can be larger than 00-23, therefore, allowing to input a duration:
obraz

@wojciechczerniak
Copy link
Contributor Author

@izulin Where are we with the missing parts? ☝️

@izulin
Copy link
Collaborator

izulin commented Apr 29, 2020

Should be done by the end of the week.

@izulin izulin mentioned this issue May 6, 2020
7 tasks
@wojciechczerniak
Copy link
Contributor Author

Finished in #342 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Something we can add later on without introducing a breaking change
Projects
None yet
Development

No branches or pull requests

3 participants