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

[Discussion] TimestampParser strictly mode. #17

Open
hiroyuki-sato opened this issue May 22, 2017 · 3 comments
Open

[Discussion] TimestampParser strictly mode. #17

hiroyuki-sato opened this issue May 22, 2017 · 3 comments

Comments

@hiroyuki-sato
Copy link
Member

For future discussion.

Current TimeStampParser allows parsing as timestamp the following data.

  • format: %Y-%m-%d %H:%M:%S.
  • input data: 2015-01-27 19:23:49 aaa(aaa is non-time data)

Some users want to use TimestampParser strictly.
It is mean that a user wants to error when above data parsed.

JRuby behavior

[1] pry(main)> Date._strptime("2017/05/22 23:12:34","%Y/%m/%d %H:%M:%S")
=> {:year=>2017, :mon=>5, :mday=>22, :hour=>23, :min=>12, :sec=>34}
[2] pry(main)> Date._strptime("2017/05/22 23:12:34 hogehogehoge","%Y/%m/%d %H:%M:%S")

=> {:year=>2017,
 :mon=>5,
 :mday=>22,
 :hour=>23,
 :min=>12,
 :sec=>34,
 :leftover=>" hogehogehoge"}

Ref(Written in Japanese)

@muga
Copy link

muga commented May 23, 2017

@hiroyuki-sato Does strictly mode mean ignore_leftover flag? I'm still not sure that TimestampParser needs to care about leftover only.

@hiroyuki-sato
Copy link
Member Author

hiroyuki-sato commented May 23, 2017

@muga
Thank you for replying.
YES, It's mean ignore_leftover flag.

The strict mode mean if the :leftover isn't nil, raise an exception.
Or return nil.

I'm not sure much about left side.

If I put no date string on the left side ex) aaa 2017/05/22 23:12:34.
It returned nil.

Date._strptime("aaa 2017/05/22 23:12:34","%Y/%m/%d %H:%M:%S")
=> nil

@dmikurube dmikurube transferred this issue from embulk/embulk Apr 10, 2023
@dmikurube
Copy link
Member

It would be considered in embulk-util-timestamp.

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

No branches or pull requests

3 participants