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 parsing #276
time parsing #276
Conversation
@wojciechczerniak please see whether you like this approach to custom time and date |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, makes sense 👍
Shouldn't we implement a sample DateTime function that should return/stringify/display a dateTime or time?
src/BuildEngineFromArraysFactory.ts
Outdated
@@ -2,7 +2,7 @@ import {HyperFormula, LazilyTransformingAstService} from './' | |||
import {CellContentParser} from './CellContentParser' | |||
import {buildColumnSearchStrategy} from './ColumnSearch/ColumnSearchStrategy' | |||
import {Config, ConfigParams} from './Config' | |||
import {DateHelper} from './DateHelper' | |||
import {DateHelper} from './DateTime' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we go with the full rename?
import {DateHelper} from './DateTime' | |
import {DateTimeHelper} from './DateTimeHelper' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is more to this file than the Helper. At one point we might split the file into -Helper and -Default
*/ | ||
parseDate: (dateString: string, dateFormats: string) => Maybe<SimpleDate>, | ||
parseDateTime: (dateTimeString: string, dateFormat: string, timeFormat: string) => Maybe<DateTime>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to report this anyway, so maybe BTW we could fix it: dateFormat
is not sufficient here. We don't have access to leapYear1900
, nullDate
, nullYear
. My suggestion would be to pass the whole Config as an argument instead of listing them all
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we shouldn't have access to those options from the level of those functions. I specifically did a refactor, so that 'parseDate' is doing what it promises: parses a date format. The logic behind transforming date object into number is hidden in the engine and shouldn't be a part of parsing function.
src/Config.ts
Outdated
* | ||
* @default defaultStringifyDate | ||
*/ | ||
stringifyDate: (date: SimpleDate, formatArg: string) => Maybe<string>, | ||
stringifyDate: (date: SimpleDate, dateFormat: string) => Maybe<string>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not stringify the DateTime object?
Sorry, I meant to write that this is WIP. I implemented first half of the issue, and will proceed to the second half now. |
OK. Let me know when it's ready for a review |
@wojciechczerniak take a look |
the only deviation from standard formatting (that is used in e.g. moment.js) is that moment.js uses HH and hh to distinguish between 24 and 12 hour formatting. But still, moment.js defines token 'a'. We use token 'a', which is ignored during time/parsing (since we allow for am/pm modifiers always anyway, but only at the end of the time-string). For printing, if there is token 'a', then we use 12h, and 24h system otherwise. |
Context
Custom time parsing.
How has this been tested?
unit tests
Types of changes
Related issue(s):
Checklist: