RTClib, write only the date, only the day of the week

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Zed67
 
Posts: 1
Joined: Sat Feb 18, 2023 2:11 am

RTClib, write only the date, only the day of the week

Post by Zed67 »

Good afternoon, gentlemen! Tell me please, I am using the excellent RTClib library for my project.
I have little difficulties, for example, I want to store only the day of the week in the watch's memory (I don't want other data to change), how can I do this?
Construction rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); changes all data at once.
I need
1. only the day of the week
2. only year, month, day
3. only hour, minutes, seconds

User avatar
adafruit_support_mike
 
Posts: 67454
Joined: Thu Feb 11, 2010 2:51 pm

Re: RTClib, write only the date, only the day of the week

Post by adafruit_support_mike »

The RTClib doesn't store values separately. At the bottom, you have a 32-bit timestamp that gets processed to supply all the other values.

If you want to change single items, you have to start by reading the current time. Then modify the values you want to change, and feed that information back to the .adjust() function.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”