Parsing question

I need to parse “2017-02-02T17:44:52+00:00” into Hour, Min, Sec. and I’m stuck.

This was parsed from http://api.sunrise-sunset.org/json?lat=36.7201600&lng=-4.4203400&formatted=0

This will be used with RTC so I can set sunset and turn on lights.

Check out sscanf()

Here is a little example I plucked for you to study.


sscanf(time,"%04d%02d%02d%02d%02d%02d",&YY,&MM,&DD,&hh,&mm,&ss);
  
  Serial.print("hour: ");   Serial.println(hh);
  Serial.print("minute: "); Serial.println(mm);
  Serial.print("second: "); Serial.println(ss);
  Serial.print("day: ");    Serial.println(DD);
  Serial.print("month: ");  Serial.println(MM);
Serial.print("year: "); Serial.println(YY);
2 Likes

I gave it a try and get, undefined reference to `sscanf’ when compiling.

Try this link

1 Like

Sscanf does not work with esp8266, any other idea’s?

Did you try os_scanf as per the first result in @Costas’s link?