Skip to content

Add ms suffix support to DurationTag - #125

Open
BehrRiley wants to merge 1 commit into
DenizenScript:masterfrom
BehrRiley:feature/millisecond-support
Open

Add ms suffix support to DurationTag#125
BehrRiley wants to merge 1 commit into
DenizenScript:masterfrom
BehrRiley:feature/millisecond-support

Conversation

@BehrRiley

Copy link
Copy Markdown

No description provided.

return new DurationTag(numVal * 0.05);
}
else if (string.endsWith("ms")) {
return new DurationTag(numVal / 1000.0);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should stick with the conversion pattern that already exists ("* 0.001" rather than "/ 1000.0").

else if (string.endsWith("t")) {
return new DurationTag(numVal * 0.05);
}
else if (string.endsWith("ms")) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This code is wrong; this branch cannot ever be hit

Comment on lines 106 to +130
if (string.endsWith("y")) {
return new DurationTag(numVal * (60 * 60 * 24 * 365));
}
else if (string.endsWith("w")) {
return new DurationTag(numVal * (60 * 60 * 24 * 7));
}
else if (string.endsWith("d")) {
return new DurationTag(numVal * (60 * 60 * 24));
}
else if (string.endsWith("h")) {
return new DurationTag(numVal * (60 * 60));
}
else if (string.endsWith("m")) {
return new DurationTag(numVal * 60);
}
else if (string.endsWith("s")) {
// seconds
return new DurationTag(numVal);
}
else if (string.endsWith("t")) {
return new DurationTag(numVal * 0.05);
}
else if (string.endsWith("ms")) {
return new DurationTag(numVal / 1000.0);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
if (string.endsWith("ms")) {
return new DurationTag(numVal * 0.001);
}
else if (string.endsWith("t")) {
return new DurationTag(numVal * 0.05);
}
else if (string.endsWith("s")) {
// seconds
return new DurationTag(numVal);
}
else if (string.endsWith("m")) {
return new DurationTag(numVal * 60);
}
else if (string.endsWith("h")) {
return new DurationTag(numVal * (60 * 60));
}
else if (string.endsWith("d")) {
return new DurationTag(numVal * (60 * 60 * 24));
}
else if (string.endsWith("w")) {
return new DurationTag(numVal * (60 * 60 * 24 * 7));
}
else if (string.endsWith("y")) {
return new DurationTag(numVal * (60 * 60 * 24 * 365));
}

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.

3 participants