rascal icon indicating copy to clipboard operation
rascal copied to clipboard

correct datetime literals fail to parse

Open jurgenvinju opened this issue 5 years ago • 3 comments

Describe the bug

rascal>$2013-07-15T09:15:23.123+03:00$
datetime: $2013-07-15T09:15:23.123+03:00$
rascal>$2013-07-15T09:15:23.12$
|prompt:///|(0,24,<1,0>,<1,24>): Invalid datetime input: Error reading time, expected digit, found: 36
Advice: |http://tutor.rascal-mpl.org/Errors/Static/DateTimeSyntax/DateTimeSyntax.html|
ok
rascal>$2013-07-15T09:15:23$
|prompt:///|(0,21,<1,0>,<1,21>): Invalid datetime input: Error reading time, expected '.', found: 36
Advice: |http://tutor.rascal-mpl.org/Errors/Static/DateTimeSyntax/DateTimeSyntax.html|
ok

jurgenvinju avatar Sep 08 '20 08:09 jurgenvinju

the parsing of the literal is deferred to the StandardTextReader of vallang, and this has hardcoded to only accept "full" datetime literals including "." and timezone offsets. It looks like this was never implemented correctly, but I believe that we did also have the simpler notation...

jurgenvinju avatar Sep 08 '20 09:09 jurgenvinju

this commit can be cherry-picked to fix this issue: https://github.com/usethesource/rascal/pull/1508/commits/68562706bcfcefcef728cc1bde2ba451d883fe91

Just checked, the standard text reader is still enforcing full offsets.

DavyLandman avatar Sep 28 '21 08:09 DavyLandman

I get this weird behavior while checking the documentation examples:

rascal>$2010-07-15T07:15:23.123+0100$.justTime
datetime: $T07:15:23.123+01:00$
rascal>$T07:15:23.123+01:00$
|prompt:///|(0,21,<1,0>,<1,21>): Invalid datetime input: Error reading time, expected ':', found: 49
Advice: |http://tutor.rascal-mpl.org/Errors/Static/DateTimeSyntax/DateTimeSyntax.html|

so we can project a "time-only" syntax but we can not parse it anymore.

jurgenvinju avatar Aug 30 '22 09:08 jurgenvinju