embulk / embulk-util-timestamp

Timestamp parser and formatter for Embulk and Embulk plugins
https://dev.embulk.org/embulk-util-timestamp/
Apache License 2.0
0 stars 0 forks source link

[Discussion] TimestampParser strictly mode. #17

Open hiroyuki-sato opened 7 years ago

hiroyuki-sato commented 7 years ago

For future discussion.

Current TimeStampParser allows parsing as timestamp the following 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 commented 7 years ago

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

hiroyuki-sato commented 7 years ago

@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 commented 1 year ago

It would be considered in embulk-util-timestamp.