Subversion Repositories Programming Utils

Rev

Rev 113 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
113 rm5248 1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
3
 * contributor license agreements.  See the NOTICE file distributed with
4
 * this work for additional information regarding copyright ownership.
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
6
 * (the "License"); you may not use this file except in compliance with
7
 * the License.  You may obtain a copy of the License at
8
 *
9
 *      http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 */
17
#include <log4cxx/logstring.h>
18
#include <log4cxx/helpers/date.h>
19
 
20
 
21
#ifndef INT64_C
22
#define INT64_C(x) x ## LL
23
#endif
24
 
115 rm5248 25
#ifndef LOG4CXX_QT
26
#include <apr_time.h>
27
#else
28
#include <QDateTime>
29
#endif
113 rm5248 30
 
31
using namespace log4cxx;
32
using namespace log4cxx::helpers;
33
 
34
IMPLEMENT_LOG4CXX_OBJECT(Date)
35
 
115 rm5248 36
#ifndef LOG4CXX_QT
113 rm5248 37
Date::Date() : time(apr_time_now()) {
38
}
115 rm5248 39
#else
40
Date::Date() : time( QDateTime::currentMSecsSinceEpoch() / 1000 ) {
41
}
42
#endif
113 rm5248 43
 
44
Date::Date(log4cxx_time_t t) : time(t) {
45
}
46
 
47
Date::~Date() {
48
}
49
 
50
log4cxx_time_t Date::getMicrosecondsPerDay() {
115 rm5248 51
#ifdef LOG4CXX_QT
52
    return 86400000000;
53
#else
113 rm5248 54
   return APR_INT64_C(86400000000);
115 rm5248 55
#endif
113 rm5248 56
}
57
 
58
log4cxx_time_t Date::getMicrosecondsPerSecond() {
115 rm5248 59
#ifdef LOG4CXX_QT
60
    return 1000000;
61
#else
113 rm5248 62
   return APR_USEC_PER_SEC;
115 rm5248 63
#endif
113 rm5248 64
}
65
 
66
 
67
log4cxx_time_t Date::getNextSecond() const {
115 rm5248 68
#ifdef LOG4CXX_QT
69
    return ((time / getMicrosecondsPerSecond()) + 1) * getMicrosecondsPerSecond();
70
#else
113 rm5248 71
    return ((time / APR_USEC_PER_SEC) + 1) * APR_USEC_PER_SEC;
115 rm5248 72
#endif
113 rm5248 73
}