예제 #1
0
static PyObject *
time_ctime(PyObject *self, PyObject *args)
{
    PyObject *ot = NULL;
    time_t tt;
    struct tm *timeptr;

    if (!PyArg_UnpackTuple(args, "ctime", 0, 1, &ot))
        return NULL;
    if (ot == NULL || ot == Py_None)
        tt = time(NULL);
    else {
        double dt = PyFloat_AsDouble(ot);
        if (PyErr_Occurred())
            return NULL;
        tt = _PyTime_DoubleToTimet(dt);
        if (tt == (time_t)-1 && PyErr_Occurred())
            return NULL;
    }
    timeptr = localtime(&tt);
    if (timeptr == NULL) {
        PyErr_SetString(PyExc_ValueError, "unconvertible time");
        return NULL;
    }
    return _asctime(timeptr);
}
예제 #2
0
static PyObject *
time_ctime(PyObject *self, PyObject *args)
{
    time_t tt;
    struct tm buf;
    if (!parse_time_t_args(args, "|O:ctime", &tt))
        return NULL;
    if (pylocaltime(&tt, &buf) == -1)
        return NULL;
    return _asctime(&buf);
}
예제 #3
0
void main()
  {
    struct tm  time_of_day;
    time_t     ltime;
    auto char  buf[26];

    time( &ltime );
    _localtime( &ltime, &time_of_day );
    tprintf( 12, 1, "Date and time is: %s\n",
            _asctime( &time_of_day, buf ) );
  }
예제 #4
0
void main()
  {
    time_t time_of_day;
    auto char buf[26];
    auto struct tm tmbuf;

    time_of_day = time( NULL );
    _gmtime( &time_of_day, &tmbuf );
    printf( "It is now: %.24s GMT\n",
            _asctime( &tmbuf, buf ) );
  }
예제 #5
0
static PyObject *
time_asctime(PyObject *self, PyObject *args)
{
    PyObject *tup = NULL;
    struct tm buf;

    if (!PyArg_UnpackTuple(args, "asctime", 0, 1, &tup))
        return NULL;
    if (tup == NULL) {
        time_t tt = time(NULL);
        buf = *localtime(&tt);
    } else if (!gettmarg(tup, &buf) || !checktm(&buf))
        return NULL;
    return _asctime(&buf);
}
예제 #6
0
int main()
{
	time_t t1, t2;
	struct tm tm1, tm2;

	time( &t1 );
	tm1 = *localtime(&t1);
	t1 = mktime(&tm1);
	tm1 = *gmtime(&t1);

	_time( &t2 );
	tm2 = *_localtime(&t2);
	t2 = _mktime(&tm2);
	tm2 = *_gmtime(&t2);

	// time, mktime
	if( t1==t2 )
		OutputDebugString( "ok\n" );
	else
	{
		static char buf[128];
		wsprintf( buf, "ng : %d, %d\n", t1, t2 );
		OutputDebugString( buf );
	}

	// localtime, gmtime
	if( 0==memcmp( &tm1, &tm2, sizeof(struct tm) ) )
		OutputDebugString( "ok\n" );
	else
		OutputDebugString( "ng\n" );

	// ctime
	OutputDebugString( ctime(&t1) );
	OutputDebugString( _ctime(&t2) );

	// asctime
	OutputDebugString( asctime(&tm1) );
	OutputDebugString( _asctime(&tm2) );

	return 0;
}