MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / getsecs

Function getsecs

src/date.cpp:536–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534 }
535
536 static const char * getsecs(const char *strp, int_fast32_t *const secsp) {
537 int num;
538
539 /*
540 ** 'HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like
541 ** "M10.4.6/26", which does not conform to Posix,
542 ** but which specifies the equivalent of
543 ** "02:00 on the first Sunday on or after 23 Oct".
544 */
545 strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1);
546 if (strp == NULL)
547 return NULL;
548 *secsp = num * (int_fast32_t) SECSPERHOUR;
549 if (*strp == ':') {
550 ++strp;
551 strp = getnum(strp, &num, 0, MINSPERHOUR - 1);
552 if (strp == NULL)
553 return NULL;
554 *secsp += num * SECSPERMIN;
555 if (*strp == ':') {
556 ++strp;
557 /* 'SECSPERMIN' allows for leap seconds. */
558 strp = getnum(strp, &num, 0, SECSPERMIN);
559 if (strp == NULL)
560 return NULL;
561 *secsp += num;
562 }
563 }
564 return strp;
565 }
566
567 static const char * getnum(const char * strp, int * const nump, const int min, const int max) {
568 char c;

Callers 2

getoffsetFunction · 0.85
getruleFunction · 0.85

Calls 1

getnumFunction · 0.85

Tested by

no test coverage detected