AceTime 3.0.0 Date and time classes for Arduino that support timezones from the TZ Database.

BrokerCommon.cpp
1 /*
2 * MIT License
3 * Copyright (c) 2021 Brian T. Park
4 */
5
6 #include <stddef.h> // size_t
7 #include <string.h> // strlen()
8 #include "compat.h" // strlen_P()
9 #include "BrokerCommon.h"
10
11 namespace ace_time {
12 namespace zoneinfo {
13
14 const char* findShortName(const char* name) {
15 size_t len = strlen(name);
16 const char* begin = name + len;
17 while (len--) {
18 begin--;
19 char c = *begin;
20 if (c == '/' || (0 < c && c < 32)) {
21 begin++;
22 break;
23 }
24 }
25 return begin;
26 }
27
28 const __FlashStringHelper* findShortName(const __FlashStringHelper* fname) {
29 const char* name = (const char*) fname;
30 size_t len = strlen_P(name);
31 const char* begin = name + len;
32 while (len--) {
33 begin--;
34 char c = pgm_read_byte(begin);
35 if (c == '/' || (0 < c && c < 32)) {
36 begin++;
37 break;
38 }
39 }
40 return (const __FlashStringHelper*) begin;
41 }
42
43 } // zoneinfo
44 } // ace_time
BrokerCommon.h
Helper functions are used in both Basic brokers and Extended brokers.
compat.h
Macros and definitions that provide a consistency layer among the various Arduino boards for compatib...