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

Add support for date, time and datetime labels #10

Open
godber opened this issue May 11, 2015 · 1 comment
Open

Add support for date, time and datetime labels #10

godber opened this issue May 11, 2015 · 1 comment

Comments

@godber
Copy link
Owner

godber commented May 11, 2015

Add support for date, time and datetime labels

https://github.com/godber/pds3label/blob/master/test/data/dates.lbl

PDS_VERSION_ID = PDS3
DATE1          = 1990-07-04
DATE2          = 1990-158
DATE3          = 2001-001
TIME1          = 12:00
TIME1_S        = 12:00:45
TIME1_S_FLOAT  = 12:00:45.4571
TIME2          = 15:24:12Z
TIME3          = 01:12:22+07
TIME4          = 01:12:22+7
TIME5          = 01:10:39.4575+07
DATE_TIME1     = 1990-07-04T12:00
DATE_TIME2     = 1990-158T15:24:12Z
DATE_TIME3     = 2001-001T01:10:39+7
DATE_TIME4     = 2001-001T01:10:39.457591+7
END

Datetime strings in the PDS label should be returned as Python Datetime objects.

@godber
Copy link
Owner Author

godber commented May 17, 2015

To do this task right, I think the grammar needs to be modified so that DATE, TIME, and DATE_TIME are grammar rules rather than tokens, unless I can find out how to access the nested tokens from the visitor level.

Basically I am thinking the following rule:

date_time_value
  : DATE
  | TIME
  | DATE_TIME
  ;

Should be something more along the line of:

date_time_value
  : DIGIT DIGIT DIGIT DIGIT '-' DIGIT+ '-' DIGIT+    # YEAR_MONTH_DAY
  | DIGIT DIGIT DIGIT DIGIT '-' DIGIT+               # YEAR_DOY
  | HH_MM_SS                                         # HH_MM_SS
  | HH_MM_SS 'Z'                                     # HH_MM_SS_Z
  | HH_MM_SS SIGN DIGIT+                             # HH_MM_SS_N
  | DATE_TIME ...
  ;

Maybe not, since DATE_TIME is DATE 'T' TIME.

Basically, what it comes down to is that in order to properly implement visitDate_time_value I think I am going to have to do a lot of string matching that should automatically happen in the grammar. Maybe I just don't get how to use it fully yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant