Hi friends, I have a problem, and I can´t solve it
I have two dates, one from the datepicker and one from the current date, what I want to do is to have the diferences in days from one date to other.
I made the blocks and it work, but for some dates i goes wrong, for eg. today is 6/3/2017 and pick the date 11/03/2017 and it work.. but if I pick 15/3/2017 I have worng answer...356 days!!!.
What do you think that I am doing wrong?
--
see the documentation and define fecha_fut accordingly
--
http://ai2.appinventor.mit.edu/reference/components/sensors.html#Clock
Returns an instant specified by MM/DD/YYYY hh:mm:ss or MM/DD/YYYY or hh:mm. An example text input is "06/22/2015 12:18"
InstantInTime MakeInstant(text from)
also you could simplify a little bit, see screenshot...
and: use Do it to debug your blocks, see tip 4 here
Top 5 Tips: How to learn App Inventor
and: use Do it to debug your blocks, see tip 4 here
Top 5 Tips: How to learn App Inventor
Thanks Taifun for your help, I don´t undestand where is the problem.... I define the variable as dd/MM/YYYY
--
Also, I simplify as you recommend :
But still not workin ..
if you take a look at the documentation, you will realize, that the MakeInstant method needs the format MM/DD/YYYY and NOT DD/MM/YYYY
InstantInTime MakeInstant(text from)
Returns an instant specified by MM/DD/YYYY hh:mm:ss or MM/DD/YYYY or hh:mm. An example text input is "06/22/2015 12:18"
--
15/3/2017 is the third of Marchtember, the 15th month of 2017.
--
WOW!!! TAIFUN you are the best!!! many thanks.....
--
Even if it is working now, you will not get the right number of days for every dates. eg. 09/15/2016 - 01/01/2004 = 4641 - you'll get 4640.
--
Alternatively, you could use DateUtils extension that uses much less blocks, auto-calculates leap years and, to my opinion, simpler to use.
--
Thanks a lot for the help!!. You are awesome!
--
@Rudolf: if you calculate the duration in hours, whats the difference then? 1 hour? probably it's a daylight saving time issue then?
which Android version are you using?
--which Android version are you using?
Maybe it's an International Date Line problem, like
--
in Around the World in 80 Days?
What's the time zone and date setting in the device or emulator?
yes it is 1 hour diff.
using
Samsung S2 - Android 4.12
Tablet - Android 4.03
Tablet - Android 4.42
time zone:
just testing dates between DST 0 +1h (give me 20 min)
--
ok
--
what happens, if you try to get the duration between 01/01/2004 and 01/11/2016 (i.e. a date outside of the daylight saving time)?
you are right
it is the DST
DST starts in Germany at march , 26 2.00am -> 3.00am
and then starts the 1h difference.
and ends October, 29 3.00am -> 2.00am
and i got the day back
So everything works, if you add 1h (i did 12h) to the date difference (in ms) . That is how I solved the problem. And now I learned why ;-)
--
댓글 없음:
댓글 쓰기