Current Day vs Selected Day

@muneer alright, I have implemented all these procedures, however, when I run the app, Thunkable crashes. I think this may have to do with the iteration of functions. I will show each function in the process:

Variables:

Getting dates:

Evaluating days in date:

Comparing date:

Calling functions:

Screen Shot 2564-10-31 at 18.14.19

Here is a link to the project.

You will have to create a test assignment to see the procedure work.

Thanks!

1 Like

I’m out now and would not be able to see the project before this evening.

One quick way to locate the error is to add a label to the screen and in the screen opens event add a text to that label prior to each function and a wait block to see what stage you are.

This way you will focus your efforts in the problem block not all the blocks.

Anyway, I’ll see it later.

[Edit]

Just went through the app and added an assignment


No crash.
Will need to test more and see what code give the issue you faced.

1 Like

If you’re interested in the days between 2 dates can’t you use that trick of calling an api that calls a Javascript to do that? or cinvery both dates to millisecond since 1970. Take the difference and convert to date? Or is the problem about parsing a manually entered date? Then it’s a challenge. Unless there’s already an api that does only that.
: convert a human entered date to task date.

2 Likes

No, it’s not.
I already designed a function to convert a seconds since 1970 to human date. As you know the first round you are focused in logic to performance. So I have it working but need to enhance it further.

Check this if you like to look into it and give me your thought of enhancing it further
https://x.thunkable.com/projectPage/617d60166771f90011dd10ea

1 Like

Hi @muneer . I am thinking about how to best implement the for loop in these procedure. I think this may be the cause for the app instability. Currently, I have implemented the loop in the last procedure:

Currently, the app will not crash when the screen is opened. However, if you navigate throughout the app and then return to the screen, Thunkable crashes. I have tried to implement this for loop throughout the procedures but nothing has resolved the issue.

Moreover, I tried your suggestion of printing values to a label in each function. This helped with fixing some of the logical errors in my code. Thanks for the tip.

Anyways, any suggestions on how I can improve app stability would be much appreciated. Here is the link:

https://x.thunkable.com/copy/56e3ad8cad86b5ed4a6096ca5efcd6da

Thanks!

1 Like

I just noticed in your code you do not process current date this causes all assignments to fall in the Overdue category.

You need to process current date by the function days in date to get correct comparisons.

1 Like

i think daysInGiverDate is mixing apples and oranges because it’s adding year and days together. for computing date differences between dates in the same year, it might work, but will fail when the years are different.

i think you should use the daysInUnixDate variable (unixdate / 86400) format as the base for subtracting dates. this is really the # of days since 1/1/1970.
if you get two dates into this format, just subtract them and you get the difference in days.
the challenge i was referring to was the conversion from standard date (year, month, day) to unixdate . the # of days since 1/1/1970 can be derived from there.

2 Likes

I can do this easily. If you like the idea in the sample project then we can, maybe, work together and design the reverse to convert from year, month, day to Unix timestamp.

2 Likes

Thanks @muneer for noticing this. I think I may have sent you an outdated link as I actually did notice that issue and resolved it:

Screen Shot 2564-11-02 at 10.13.52

The conditions are now working (I still need to refine them). However, there is still a major issue with app stability. It is prone to crashes quite a lot which I believe is down to the for loop. Any suggestions would be much appreciated.

Thanks!

@muneer please ignore my previous replies, I have an update. The procedures are now working smoothly and the app stability has been improved. The crashes were due to the functions being called simultaneously at different point in the code. There is one final thing I would like to implement.

Currently, the code parses the dates and adds a label when the screen is opened and when an assignment is added. However, this is a problem as the for loop implemented within the function keeps adding the label every time when either of these events occurs. Therefore, would it be possibly to implement a condition that only adds the label to assignments without one? Additionally, the labels would need to be updated once the current date changes. Any suggestions on how to do this? Here is the link:

https://x.thunkable.com/copy/3a2b3226d582ea825d22f88d7c834bd1

Thanks!

1 Like

You can do something similar to the function All Filled.

Create a function to receive the text entry as its parameter and check that none of the status wordings is available and return true or false according to the situation then you only process the ones that are not processed yet.

1 Like

That sounds like a great idea @muneer . One thing, how would make it so that the list items are indeed processed when the current date changes? If the user’s task contains the label ‘Due today!’, how would the code update the label to ‘Overdue’ once the due date has passed?

Update

@muneer , I have had a go at making the function you suggested:

This function goes through each list item to check if it contains a due date status:

Screen Shot 2564-11-02 at 19.42.19

It is called in this function:

The procedure is not working though. I think this may be due to the fact that the ‘compare dates’ function is a for loop and is calling the other ‘check due date status’ function which is also a for loop. I am not too sure. Any suggestions would be much appreciated.

Thanks!

1 Like

You need only the IF conditions without the loop. You will check the condition before updating the status and if status is available then remove it along with the new line character prior to it.

image

This is the sample block.

1 Like

@muneer I have tried to make this a function with the parameter assignment so that I can call this throughout the code:

However, when I call this in a different function passing j as assignment, the function is not completed:

This procedure worked fine when I did not add a parameter to the function but I want to add a parameter so I can pass in different variables. Any idea on what could be causing this?

Thanks!

i found an article (written by Victor Vogelpoel in 2002!) that shows how to convert year-month-day to excel serial date and back. it’s pretty cool! it only takes a little adjustment to make it work for unix dates. i translated it to thunkable and it works!

here’s the project (warning: the formulas are ugly!)
https://x.thunkable.com/copy/31e9f95fec50f854e131dad9f2f05f57

right now it recognizes unix dates in milliseconds, but you can convert them to days by dividing by 86400. the calendar date needs to be entered as in 2021-12-31 (hyphens between the parts).

this is the time we need a function in thunkable IDE to be able to “textify” (convert to text) blocks AND a reverse function to “blockify” the text back to blocks. this would eliminate the re-typing we have to do when we want to bring a subroutine into our program. just wishful thinking. or better yet, if we only had a way of building thunkable libraries!

1 Like

Yes, that would be very useful! A great suggestion for @domhnallohanlon .

@muneer , how would I make this as a function that I could pass variables in:

I have currently made this however, it does not accept ‘j’ as a variables:

image

1 Like

This is how I would do it.

2 Likes

@muneer , is there a way of passing a parameter like I tried to do above? This is because when the user deletes an assignment, the assignment is archived. I would therefore like the due date status to be removed from archived assignments. I could use this function and pass in ‘item’ as ‘assignment’ when a list item is clicked.

The only issue is that it is not being completed as outlined above. When I pass in ‘j’ (the list item), it is not being processed by the function. Any idea why this could be occurring?

Thanks!

1 Like