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

[MRG] allow for n/a to be a valid date in acq_time #539

Merged
merged 2 commits into from
Aug 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/tsv.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ describe('TSV', function() {
})
})

it('should allow n/a as acq_time column entries', function() {
const tsv = 'filename\tacq_time\n' + 'value-one\tn/a'
validate.TSV.TSV(scansFile, tsv, [], function(issues) {
assert.deepEqual(issues, [])
})
})

it('should allow properly formatted acq_time column entries', function() {
const tsv = 'filename\tacq_time\n' + 'value-one\t2017-05-03T06:45:45'
validate.TSV.TSV(scansFile, tsv, [], function(issues) {
Expand Down
5 changes: 4 additions & 1 deletion validators/tsv.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ const checkAcqTimeFormat = function(rows, file, issues) {
const line = testRows[i]
const lineValues = line.trim().split('\t')
const acqTime = lineValues[acqTimeColumn]
const isValid = dateIsValid(parseDate(acqTime, format, new Date()))
var isValid = dateIsValid(parseDate(acqTime, format, new Date()))
if (acqTime === 'n/a') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if acqTime is 'n/a' why does parseDate not throw an error?

Copy link
Member Author

Choose a reason for hiding this comment

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

it returns Invalid Date if the parsing according to format fails

isValid = true
}
if (acqTime && !isValid) {
issues.push(
new Issue({
Expand Down