Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add to/Subtract from date not producing a valid Shortcut when the magnitude is a variable #35

Closed
mikeogezi opened this issue Dec 6, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@mikeogezi
Copy link
Contributor

Describe the bug
Add to date:

addSeconds(string date, integer magnitude)
addMinutes(string date, integer magnitude)
addHours(string date, integer magnitude)
addDays(string date, integer magnitude)
addWeeks(string date, integer magnitude)
addMonths(string date, integer magnitude)
addYears(string date, integer magnitude)

&

Subtract from date:

subtractSeconds(string date, integer magnitude)
subtractMinutes(string date, integer magnitude)
subtractHours(string date, integer magnitude)
subtractDays(string date, integer magnitude)
subtractWeeks(string date, integer magnitude)
subtractMonths(string date, integer magnitude)
subtractYears(string date, integer magnitude)

do not produce valid shortcuts when the magnitude is a variable.

To Reproduce

@d = date("October 5, 2022")
@a = 2
addDays(d, a)

Debug output
The compilation is successful, but below is a screenshot of the Shortcut.

Screenshot 2023-12-05 at 6 41 27 PM

Expected behavior

Screenshot 2023-12-05 at 6 43 15 PM

Screenshots
See above.

Version Information (please complete the following information):

  • macOS version (run uname -a): Darwin Michaels-MacBook-Air.local 23.2.0 Darwin Kernel Version 23.2.0: Fri Oct 13 09:28:08 PDT 2023; root:xnu-10002.60.54~14/RELEASE_ARM64_T8112 arm64
  • Golang version (run go version): go version go1.21.4 darwin/arm64

Additional context
N/A

@mikeogezi mikeogezi added the bug Something isn't working label Dec 6, 2023
@mikeogezi
Copy link
Contributor Author

@electrikmilk, if you could give me a few pointers for some of these past issues, I might be able to help.

@electrikmilk electrikmilk self-assigned this Dec 13, 2023
electrikmilk added a commit that referenced this issue Dec 13, 2023
@electrikmilk
Copy link
Owner

electrikmilk commented Dec 13, 2023

@electrikmilk, if you could give me a few pointers for some of these past issues, I might be able to help.

Sure, I will do my best. A lot of these issues boil down to variations in data structure for these different actions. They require a custom structure for the value of one of their parameters. Thus they require adding a custom solution to fit their data structure and insert a variable or an inline variable value into their parameters within a make function defined on the action definition.

For example with this issue, these date actions have their make function called adjustDate() which creates them based on the structure for this type of action. In this case, this has a custom structure for the magnitude value that has a custom serialization type to specify (which most action parameters do not need to specify) and a unit value that needs to be in the same data as the magnitude value, this is not standard for the rest of the actions in the compiler.

For more insight on this fix, check out 04a4e8a, which fixes this issue.

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

No branches or pull requests

2 participants