- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is there an API that will convert the CURRENT_TIME and LOCAL_TIME_INFO received from a CTS into UTC time?
Cheers,
Mike
Solved! Go to Solution.
- Labels:
-
PSoC 4 MCU
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Attached is the code I wrote for an IoT PoC Project a few years ago.
In mcu_time.c line 31, I wrote
uint32_t utc_offset = 9 * 60 * 60 ;
as JST is +9.
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I wonder if the following sample code can be some help?
https://community.cypress.com/t5/Code-Examples/CY8CKIT-044-RTC-with-32kHz-Crystal-Sample/td-p/95862
moto
P.S. In RTC.h there are functions, like
uint64 RTC_ConstructUnixAlarmTime(const RTC_DATE_TIME* alarmTime, uint8 alarmCfgMask);
uint64 RTC_GetDstUnixTime(const RTC_DST_TIME* dstTime);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Moto,
Thanks for the reply. Unfortunately that's more dealing with converting time from "standard" format to BCD, so it can be stored in the RTC. I've managed to get that conversion working so I can write and read from my RTC.
I'm reading the local time off a Current Time Service (my iPhone), but want to store it in the RTC as UTC time.
Seems simple enough to add/delete the time zone and DST offsets, but of course if (as is my case here in Australia) your local time is on the next day compared to UTC when you do the time read/conversion, you potentially need to make adjustments to day of the week, day of the month, month and year! I was hoping someone had done the hard work of writing a suitable function to achieve this already 🙂
Cheers,
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi, Mike-san,
I'm just curious, but have you taken a look at my mcu_time.c?
I though that I tried the "hard work" in ts2time() and ts2tm().
moto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Moto,
My apologies - I didn't see your second post. Had a quick look over those two functions, and I think ts2time() may have given me a few ideas on how to make my Convert2UTC() function a bit neater!
Arigatoo gozaimasu!
Mike
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Mike-san,
> Arigatoo gozaimasu!
Dou Itashimasite!
moto