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

Fractional date bug 1361 #148

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fractional date bug 1361 #148

wants to merge 2 commits into from

Conversation

bklaing2
Copy link
Member

Purpose

Fixed issue where dates with fractional times wouldn't be returned from API

closes: datacite/datacite#1361

Approach

Added Time.iso8601 to handle fractional times

Open Questions and Pre-Merge TODOs

Learning

Researched different ways to handle parsing dates with fractional times according to the schema. Found a class which looked promising, but ended up not being supported for the version ruby we're using. After a bit more research I settled on using the Time.iso8601 method.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

Reviewer, please remember our guidelines:

  • Be humble in the language and feedback you give, ask don't tell.
  • Consider using positive language as opposed to neutral when offering feedback. This is to avoid the negative bias that can occur with neutral language appearing negative.
  • Offer suggestions on how to improve code e.g. simplification or expanding clarity.
  • Ensure you give reasons for the changes you are proposing.

"dateInformation" => parse_attributes(r, content: "dateInformation")
}.compact
end
rescue
Copy link
Contributor

@jrhoads jrhoads Oct 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is my first time seeing rescue nil?
Does this catch all exceptions? That might be too broad. If there are specific types of exceptions we need to guard against, it could be good to specify the type.

If this was more about providing a default value, nill should be returned if the if statement fails.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes rescue nil is very broad, a quick google also suggests some articles it's quite slow.
What's the actual exception being thrown and from what bit? The time.iso8601?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the rescue is for the Time.iso8601 method. It throws errors if the date format is wrong, whereas the Date.edtf method doesn't. I can narrow down the rescue to more specific exceptions though

@@ -1653,4 +1653,12 @@
)
end

it "Parses dates with fractional seconds" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a new test as well, that also handles the ranges we talked about.
Simplest way might be to make the fixture actually just something like datacite-example-dates.xml
and then have both a fractional date in it and also a date with a range.
then add some expects for both.

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

Successfully merging this pull request may close these issues.

Fractional dates are not returned via the API
3 participants