Mateja
(Mateja)
April 18, 2020, 8:41am
#1
This is my first contribution to the #daily-challenge category.
Your task is to create a simple app that shows how many months, weeks and days are you in the current year.
Result for 18/4/2020
=> 3 months, 2 weeks, 4 days
Of course, you can use the device time.
Rules:
You can’t use an online API
Have fun
Calendar
3 Likes
vknow360
(Sunny Gupta)
April 18, 2020, 11:09am
#2
There can be multiple solutions and it is one of them:
1 Like
Mateja
(Mateja)
April 18, 2020, 11:18am
#3
What date are you using? Today’s? If so, the result should be
3 months, 2 weeks, 4 days
vknow360
(Sunny Gupta)
April 18, 2020, 11:32am
#4
I think you too are confused.
Mateja:
2 weeks, 6 days
If this is result then today’s date will be:
Today’s date: 2*7+6 = 14+6 = 20
but today is 18.
So 2 weeks , 4 days is the correct answer.
And for this:
Mateja:
4 months 3 months
Clock counts current month also so we have to subtract 1 to get correct result.
Mateja
(Mateja)
April 18, 2020, 11:36am
#5
Ah, true.
Well, not in every case. If the day is the last day of the month, we set the day to 0 and set the month to the current month. I edited my topic.
1 Like
vknow360
(Sunny Gupta)
April 18, 2020, 11:40am
#6
Wait for more answers man…
Mateja
(Mateja)
April 22, 2020, 6:23am
#9
Nice job, I will import the blocks and test it.
I built this logic but I can’t test using a mobile phone. because I don’t have any smartphone phone.
Mateja
(Mateja)
April 22, 2020, 6:46am
#11
Just a small correction. According to wikipedia, a leap year is if ((year%4==0 || year%400==0) && year%100!=0)
, meaning that for year 2100 your program would return True
, even tho it should be False
1 Like
Thank you so much for your info. this is very helpful for me. is other blocks are correct ?
system
(system)
Closed
May 22, 2020, 6:50am
#14
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.