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

Adding optional timestamp field #18

Merged
merged 1 commit into from
Feb 8, 2019
Merged

Adding optional timestamp field #18

merged 1 commit into from
Feb 8, 2019

Conversation

peolivei2
Copy link
Collaborator

Allows users to optionally specify the date and time of measurements.

@@ -39,12 +39,22 @@ module.exports = async function (context, device, measurements) {
throw new StatusError('Invalid format: invalid measurement list.', 400);
}

if (timestamp && isNaN(Date.parse(timestamp))) {
Copy link
Member

Choose a reason for hiding this comment

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

if someone passes '' or 0 for timestamp will that cause problems?

i'd probably tighten the first part of the check to be safe

Suggested change
if (timestamp && isNaN(Date.parse(timestamp))) {
if (timestamp != null && isNaN(Date.parse(timestamp))) {

Copy link
Member

Choose a reason for hiding this comment

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

ah okay i see the condition below. consider this optional depending on whether you want to tell the user that falsy values won't do anything

Copy link
Member

@princjef princjef left a comment

Choose a reason for hiding this comment

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

LGTM

@peolivei2 peolivei2 merged commit 95b58c7 into master Feb 8, 2019
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.

None yet

2 participants