NTPClient icon indicating copy to clipboard operation
NTPClient copied to clipboard

how to retrieve dayOfWeek, day, month, year?

Open dsyleixa opened this issue 5 years ago • 5 comments
trafficstars

how to retrieve dayOfWeek, day, month, year? (either using Unix time string or via extra functions, feat time zone offsets) an example sketch shipping with this lib would be highly appreciated!

dsyleixa avatar Dec 25 '19 12:12 dsyleixa

This for Day, Month and Year: https://randomnerdtutorials.com/esp32-ntp-client-date-time-arduino-ide/ And for Day of the Week you could use some kind of counter function, containing all Weekdays(Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday) and starting from a known Date with Weekday with counting...

Edit: Looks like someone made the Fix for this code here(didnt tried it myself): https://github.com/gmag11/NtpClient/issues/84

SyCoTechs avatar Feb 06 '20 21:02 SyCoTechs

tbh, the split function of formatted date is quite complicated in order to get dayOfWeek, day, month, year in exactly that order additionally to time (hours, minutes, seconds, perhaps millisec) It would be easier to get them by dedicated direct-call functions like

  • int formattedDate.hours
  • int formattedDate.minutes
  • int formattedDate.seconds
  • int formattedDate.millisec
  • char* formattedDate.dayOfWeek or String formattedDate.dayOfWeek
  • int formattedDate.day
  • int formattedDate.month
  • int formattedDate.year

dsyleixa avatar Feb 06 '20 22:02 dsyleixa

@dsyleixa dedicated direct-call functions are available Please refer that.

thekunalsaini avatar Mar 20 '20 07:03 thekunalsaini

@dsyleixa dedicated direct-call functions are available Please refer that.

what do you want to express? what is available? where is the documentation about all and everything? where are all the related code examples?

dsyleixa avatar Mar 20 '20 11:03 dsyleixa

I'd also like to get day/month/year functions, as that would allow to implement daylight saving properly (as that actually follows quite simple rules in most places). Also for other use cases these might be convenient.

PS: #94 would address this topic, for example.

FrankyBoy avatar Jun 27 '20 08:06 FrankyBoy