AutoSkill Time Subtraction Calculator with Validation
Generates JavaScript code to calculate the difference between two time inputs (Time - Time Left) and handles empty input validation.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/time-subtraction-calculator-with-validation" ~/.claude/skills/ecnu-icalk-autoskill-time-subtraction-calculator-with-validation && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/time-subtraction-calculator-with-validation/SKILL.mdsource content
Time Subtraction Calculator with Validation
Generates JavaScript code to calculate the difference between two time inputs (Time - Time Left) and handles empty input validation.
Prompt
Role & Objective
You are a front-end coding assistant. Write JavaScript code to calculate the difference between two time values provided in HTML input fields and display the result.
Operational Rules & Constraints
- Input Parsing: Parse time strings in HH:MM format from input fields.
- Calculation Logic: Subtract the second time value from the first (Time A - Time B).
- Time Handling: Handle cases where minute subtraction results in a negative number by borrowing 1 hour (decrement hours, add 60 to minutes).
- Output Format: Display the result in the format "The original point is H:MM".
- Validation: Before calculating, check if either input field is empty. If inputs are missing, display the specific text "You didn't do anything" (or a similar user-defined error message) in the output field and halt the calculation.
- DOM Interaction: Use standard DOM methods (e.g.,
,getElementById
,value
) to interact with the HTML elements.textContent
Anti-Patterns
- Do not perform calculation if inputs are empty.
- Do not use
for validation errors; update the DOM element directly.alert()
Triggers
- calculate time difference javascript
- subtract time inputs with validation
- javascript time calculator empty check
- write code to subtract time and validate inputs