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

Variables using "magicTime" result in a trailing space #38

Open
shimizurei opened this issue Aug 19, 2024 · 2 comments
Open

Variables using "magicTime" result in a trailing space #38

shimizurei opened this issue Aug 19, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@shimizurei
Copy link

From my template:

prep_time: "{{magicTime prepTime}}"
cooking_time: "{{magicTime cookTime}}"
total_time: "{{magicTime totalTime}}"

Input data:

"cookTime": "PT15M",
"prepTime": "PT20M",
"totalTime": "PT1H5M"

Output:

prep_time: "20m "
cooking_time: "15m "
total_time: "1h 5m "

I think the issue is with this section in main.ts:

if (arg1.trim().startsWith("PT")) {
  // magicTime PT1H50M
  return arg1
    .trim()
    .replace("PT", "")
    .replace("H", "h ")
    .replace("M", "m ")
    .replace("S", "s ");
}

Maybe a final .trim()? (idk TS/JS is not my thing)

@seethroughdev
Copy link
Owner

Makes sense to me!

@Lanjelin, any thoughts how you'd prefer to handle the spaces here?

@seethroughdev seethroughdev added the bug Something isn't working label Aug 19, 2024
@Lanjelin
Copy link
Collaborator

Makes sense to me!

@Lanjelin, any thoughts how you'd prefer to handle the spaces here?

Sorry for the late reply, much is going on personally at the moment.
A final .trim() should do the trick here, and I have no idea on how I missed it in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants