We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Showing wrong time for New York
The text was updated successfully, but these errors were encountered:
try{ // make the request Response response = await get('http://worldtimeapi.org/api/timezone/$url'); Map data = jsonDecode(response.body); // get properties from json String datetime = data['datetime']; String offset = data['utc_offset'].substring(1,3); String sign = data['utc_offset'].substring(0,1); print("sign is $sign"); // create DateTime object DateTime now = DateTime.parse(datetime); now = sign == '+'? now.add(Duration(hours: int.parse(offset))):now.subtract(Duration(hours: int.parse(offset))); // set the time property isDaytime = now.hour > 6 && now.hour < 20 ? true : false; time = DateFormat.jm().format(now); }
Add ternary operator to read UTC value and add/substract based on that
Sorry, something went wrong.
No branches or pull requests
Showing wrong time for New York
The text was updated successfully, but these errors were encountered: