Personal tools
You are here: Home Projects C++ Cfront releases Release 3.0.3 source libSC Time tm tmgoff.c
Document Actions

tmgoff.c

by Michael L Powell last modified 2007-01-26 03:24

Click here to get the file

Size 1.1 kB - File type text/plain

File contents

/*ident	"@(#)Time:tm/tmgoff.c	3.1" */
/******************************************************************************
*
* C++ Standard Components, Release 3.0.
*
* Copyright (c) 1991, 1992 AT&T and Unix System Laboratories, Inc.
* Copyright (c) 1988, 1989, 1990 AT&T.  All Rights Reserved.
*
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T and Unix System
* Laboratories, Inc.  The copyright notice above does not evidence
* any actual or intended publication of such source code.
*
******************************************************************************/

#include <tm.h>
#include <ctype.h>

/*
 * return minutes offset from [[-+]hh[:mm[:ss]]] expression
 *
 * if e is non-null then it points to the first unrecognized char in s
 * d returned if no offset in s
 */

int tmgoff_ATTLC(register char* s, char** e, int d) {
	register int	n;
	char*		t;

	if (isdigit(n = *s) || n == '-' || n == '+')
	{
		n = (int)strtol(s, &t, 10);
		if (t > s)
		{
			n *= 60;
			if (*t == ':') n += (n < 0 ? -1 : 1) * (int)strtol(t + 1, &t, 10);
			if (*t == ':') (void)strtol(t + 1, &t, 10);
		}
		else n = d;
	}
	else
	{
		n = d;
		t = s;
	}
	if (e) *e = t;
	return(n);
}
« March 2024 »
Su Mo Tu We Th Fr Sa
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: