DateTimeParser v1.0.0 DateTimeParser.Parser behaviour View Source
Interface for the DateTimeParser to use when parsing a string.
The flow is:
- Preflight the string to see if the parser is appropriate. Sometimes the parsing can happen at
this stage if it's a simple parser, for example it can be done in a single regex. Results of the
preflight, if needed, can be stored in the
struct.preflight
. - Parse the string. You have
context/0
to check if you should return a time, date, or datetime. Also make sure you're honoring the user's options supplied instruct.opts
You may create your own parser and use it with the DateTimeParser by creating a module that follows this behaviour.
Link to this section Summary
Callbacks
Parse the string.
Determine if the string is appropriate to parse with this parser. If not, then other parsers will be attempted.
Link to this section Types
Link to this section Callbacks
Link to this callback
parse(t)
View Sourceparse(t()) :: {:ok, DateTime.t() | NaiveDateTime.t() | Time.t() | Date.t()} | {:error, any()}
Parse the string.
Determine if the string is appropriate to parse with this parser. If not, then other parsers will be attempted.