I am using flutter to build an app, so therefore I am also using dart. I need to use the DateTime class for a calendar.
When I execute the following line of code:
print(DateTime.now())
It prints:
2022-12-29 15:27:11.147472
I executed this code on 2023-01-04 and I executed the code at about 3:03 pm.
How do I fix this?
Thanks!
The issue was that the simulator that I was running the program on had the wrong date so it made the app show the wrong date as well.
Thank you to Soliev for helping me with the issue!
There might be a problem with the device's system clock. Make sure that the device's system clock is set to the correct date and time.
There might be a problem with the device's time zone settings. Make sure that the device's time zone settings are correct.
There might be a problem with the app's code. Double-check the code to make sure that there are no errors or bugs that could be causing the incorrect date and time to be returned
Related
I am currently developing an application with Flutter where I use the Google Maps API but I am having a problem with the display of data.
Indeed in my application it displays the arrival time (arrival_time) like this: 7:19pm.
But I would like it to display in this form: 19:19
Same for the travel time (duration) it displays 1hour24mins but I would like it to display 1h24.
How do I deal with these problems?
Thanks a lot for your help
Cordially
Thibault
Here is a screenshot:
If you can transform this dates to DateTime, then you could use intl package to transform the time.
For instance:
DateTime t = DateTime.now();
print(DateFormat.Hm().format(t));
This prints the time in 24 hours format.
You would also probably be able to also transform it to XhYm too.
Thanks a lot for your help.
So there you have it, I tried your solutions but it doesn't work.
What is strange is that when I call the API with a browser (Chrome) it displays the correct time (16:48).
But when I try in the app it returns 4:48 pm.
And suddenly I don't know how to solve this problem.
So if there are any additional parameters to pass, I would like to have them.
Thank you for your time
Cordially
Thibault
I found something for the selenium test but I dont see something for manually browsing. It looks like GMT is allways used.
I look for a way to test my local site with a specific timezone. Setting the timezone for the machine would also change the timezone for my local webserver (iis on windows) and thats not what I want.
I know I can set the time offset for firefox but this is also not my preferred way, because it realy sets an offset not a timezone with a different behaviour for daylight saving time.
Currently, changing the time zone on BrowserStack 'Live' is unavailable. However, we have made a note of your request and will keep you posted.
Mukesh from BrowserStack
You can use browserstack.timezone capabilities. For more information refer https://www.browserstack.com/automate/capabilities
I'm using GitHub API v3 to connect to a repository and get the list of issues that were update/created since a specific date. I use these parameters to get a filtered result:
filter: all
labels: bug
state: all
sort: updated
direction: ascendent
since: date
If i find any result, for each issue I get the issue events that triggered a change (filtering for the ones that happened since date).
Everything works fine for every issue event except for locked and unlocked
events that, for some reason, don't update the issue updated field.
This leads to the inability to get then the list of issues that were updated since that specific date and therefore I don't check for the issue events.
Questions:
Is there a reason why these two events don't update the issue?
Is there an acceptable solution, except for the one where I should get all the issues and query them manually?
As of today (4th of October, 2015), I cannot reproduce this issue. If it was reproducible when the question was posted, probably it was a bug, not a feature.
Is there a reason why these two events don't update the issue?
They do update the issue (see the updated_at field) and the since parameter works fine.
Is there an acceptable solution, except for the one where I should get all the issues and query them manually?
Just use the since parameter, the way how it is supposed to work, but keep in mind the timezone could be different. Since you're in Romania (like me! :-)) and your server could be into another timezone, you may want to modify the date to match the Romanian time. That's most probably your issue. Just add/substract few hours and see if that helps.
curling the issues, I cannot reproduce the behavior you have.
On the other side, you may want to use the locked parameter which is anyway updated.
I just came across a bug in my program, that has me confused. I add several events to the iPhone calendar in my app. I found that when I receive a "No end date has been set." error when calling saveEvent:span:error:, all subsequent calls to saveEvent:span:error: result in the same error message. If I change the culprit object to be valid, all events save successfully. Has anybody ran into this? Or do you know why one error might cause all future calls to result in the same error?
I know that I just need to not save an event with no end date set to fix this, but I would like to know why this is happening.
Thanks.
I figured this out. There is a bug in the EKEvent SDK on iOS 5 that is causing this. Hopefully it will be fixed in the first update to iOS 5.
Solution:startDate and endDate should be different.
[event setStartDate:date];
[event setEndDate:[date dateByAddingTimeInterval:1.0]];
Im building a calendar and to find out the first day of the month I do
[formatter setDateFormat:#"e"];
int startDay = [[formatter stringFromDate:newDate] intValue];
On the device this works correctly and the 1st of the month is on the correct day. But on the simulator it is the day after. Although it doesn't overly matter about the simulator it is kind of driving me crazy thinking I've done something wrong. I tried to set the locale of the formatter but no difference, nor i think should it. Can anyone shed some light on this?
On a side note is there a better way to build a calendar than this?
Update: It seems if I dont set the locale it works fine on device but on the simulator it doesn't. If I do set the locale to en_US neither of them work. I'm in Aust if that changes anything but I'm pretty sure both the US and Aust have the same calendar :/
That sounds like correct behavior depending on the date you're passing in. An NSDate corresponds to a precise point in universal time. At that point, it may be Monday in one time zone and Tuesday in another.
You probably want [[NSCalendar currentCalendar] firstWeekDay].
There doesn't seem to be a solution to this. Changing the timezone on the device doesn't cause an issue and all log output reports the proper timezone but NSDate seems to pull the timezone from two different locations on the simulator, probably one for Cupertino and one for local.
Looking at other peoples solution to getting the first day of the month it is the same as my code (odd because I didn't copy) and no one has reported a problem, perhaps those users were in the U.S and so the problem didn't surface. Changing the timezone on the computer doesn't do anything either.
What if you have different Calendars on Emulator and Device? One has Monday as a firstWeekDay and another has Sunday. Probably this could be a reason of the problem...