Skip to content

Commit

Permalink
Add VxWorks support (#260)
Browse files Browse the repository at this point in the history
A little code is changed for:
strptime() is not supported by VxWorks.
The time zone variables in VxWorks are: timezone and tzname.
  • Loading branch information
wenshan1 authored Jun 8, 2023
1 parent 13b90c8 commit b43d4d2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/time_zone_format.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// limitations under the License.

#if !defined(HAS_STRPTIME)
# if !defined(_MSC_VER) && !defined(__MINGW32__)
# if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(__VXWORKS__)
# define HAS_STRPTIME 1 // assume everyone has strptime() except windows
// and VxWorks
# endif
#endif

Expand Down
10 changes: 10 additions & 0 deletions src/time_zone_libc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ auto tm_zone(const std::tm& tm) -> decltype(tzname[0]) {
const bool is_dst = tm.tm_isdst > 0;
return tzname[is_dst];
}
#elif defined(__VXWORKS__)
// Uses the globals: 'timezone' and 'tzname'.
auto tm_gmtoff(const std::tm& tm) -> decltype(timezone + 0) {
const bool is_dst = tm.tm_isdst > 0;
return timezone + (is_dst ? 60 * 60 : 0);
}
auto tm_zone(const std::tm& tm) -> decltype(tzname[0]) {
const bool is_dst = tm.tm_isdst > 0;
return tzname[is_dst];
}
#else
// Adapt to different spellings of the struct std::tm extension fields.
#if defined(tm_gmtoff)
Expand Down

0 comments on commit b43d4d2

Please sign in to comment.