2 * Copyright (C) 2005 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef ANDROID_TIME_H
18 #define ANDROID_TIME_H
21 #include <cutils/tztime.h>
23 #include <sys/types.h>
25 #include <utils/String8.h>
26 #include <utils/String16.h>
31 * This class is the core implementation of the android.util.Time java
32 * class. It doesn't implement some of the methods that are implemented
33 * in Java. They could be done here, but it's not expected that this class
34 * will be used. If that assumption is incorrect, feel free to update this
35 * file. The reason to do it here is to not mix the implementation of this
36 * class and the jni glue code.
43 // this object doesn't own this string
57 static int compare(Time& a, Time& b);
61 void switchTimezone(const char *timezone);
62 String8 format(const char *format, const struct strftime_locale *locale) const;
63 void format2445(short* buf, bool hasTime) const;
64 String8 toString() const;
66 int64_t toMillis(bool ignoreDst);
67 void set(int64_t millis);
69 inline void set(int sec, int min, int hour, int mday, int mon, int year,
74 this->t.tm_hour = hour;
75 this->t.tm_mday = mday;
77 this->t.tm_year = year;
78 this->t.tm_isdst = isdst;
80 this->t.tm_gmtoff = 0;
87 }; // namespace android
89 #endif // ANDROID_TIME_H