• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
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
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /*
17  * Elements of the WallTime class are a port of Bionic's localtime.c to Java. That code had the
18  * following header:
19  *
20  * This file is in the public domain, so clarified as of
21  * 1996-06-05 by Arthur David Olson.
22  */
23 
24 package com.android.i18n.timezone;
25 
26 
27 /**
28  * A class that represents a "wall time". This class is modeled on the C tm struct and
29  * is used to support android.text.format.Time behavior. Unlike the tm struct the year is
30  * represented as the full year, not the years since 1900.
31  *
32  * <p>This class contains a rewrite of various native functions that android.text.format.Time
33  * once relied on such as mktime_tz and localtime_tz. This replacement does not support leap
34  * seconds but does try to preserve behavior around ambiguous date/times found in the BSD
35  * version of mktime that was previously used.
36  *
37  * <p>The original native code used a 32-bit value for time_t on 32-bit Android, which
38  * was the only variant of Android available at the time. To preserve old behavior this code
39  * deliberately uses {@code int} rather than {@code long} for most things and performs
40  * calculations in seconds. This creates deliberate truncation issues for date / times before
41  * 1901 and after 2038. This is intentional but might be fixed in future if all the knock-ons
42  * can be resolved: Application code may have come to rely on the range so previously values
43  * like zero for year could indicate an invalid date but if we move to long the year zero would
44  * be valid.
45  *
46  * <p>All offsets are considered to be safe for addition / subtraction / multiplication without
47  * worrying about overflow. All absolute time arithmetic is checked for overflow / underflow.
48  *
49  * @hide
50  */
51 
52 @SuppressWarnings({"unchecked", "deprecation", "all"})
53 public class WallTime {
54 
WallTime()55 public WallTime() { throw new RuntimeException("Stub!"); }
56 
57 /**
58  * Sets the wall time to a point in time using the time zone information provided. This
59  * is a replacement for the old native localtime_tz() function.
60  *
61  * <p>When going from an instant to a wall time it is always unambiguous because there
62  * is only one offset rule acting at any given instant. We do not consider leap seconds.
63  */
64 
localtime(int timeSeconds, com.android.i18n.timezone.ZoneInfoData zoneInfo)65 public void localtime(int timeSeconds, com.android.i18n.timezone.ZoneInfoData zoneInfo) { throw new RuntimeException("Stub!"); }
66 
67 /**
68  * Returns the time in seconds since beginning of the Unix epoch for the wall time using the
69  * time zone information provided. This is a replacement for an old native mktime_tz() C
70  * function.
71  *
72  * <p>When going from a wall time to an instant the answer can be ambiguous. A wall
73  * time can map to zero, one or two instants given rational date/time transitions. Rational
74  * in this case means that transitions occur less frequently than the offset
75  * differences between them (which could cause all sorts of craziness like the
76  * skipping out of transitions).
77  *
78  * <p>For example, this is not fully supported:
79  * <ul>
80  *     <li>t1 { time = 1, offset = 0 }
81  *     <li>t2 { time = 2, offset = -1 }
82  *     <li>t3 { time = 3, offset = -2 }
83  * </ul>
84  * A wall time in this case might map to t1, t2 or t3.
85  *
86  * <p>We do not handle leap seconds.
87  * <p>We assume that no timezone offset transition has an absolute offset > 24 hours.
88  * <p>We do not assume that adjacent transitions modify the DST state; adjustments can
89  * occur for other reasons such as when a zone changes its raw offset.
90  */
91 
mktime(com.android.i18n.timezone.ZoneInfoData zoneInfo)92 public int mktime(com.android.i18n.timezone.ZoneInfoData zoneInfo) { throw new RuntimeException("Stub!"); }
93 
setYear(int year)94 public void setYear(int year) { throw new RuntimeException("Stub!"); }
95 
setMonth(int month)96 public void setMonth(int month) { throw new RuntimeException("Stub!"); }
97 
setMonthDay(int monthDay)98 public void setMonthDay(int monthDay) { throw new RuntimeException("Stub!"); }
99 
setHour(int hour)100 public void setHour(int hour) { throw new RuntimeException("Stub!"); }
101 
setMinute(int minute)102 public void setMinute(int minute) { throw new RuntimeException("Stub!"); }
103 
setSecond(int second)104 public void setSecond(int second) { throw new RuntimeException("Stub!"); }
105 
setWeekDay(int weekDay)106 public void setWeekDay(int weekDay) { throw new RuntimeException("Stub!"); }
107 
setYearDay(int yearDay)108 public void setYearDay(int yearDay) { throw new RuntimeException("Stub!"); }
109 
setIsDst(int isDst)110 public void setIsDst(int isDst) { throw new RuntimeException("Stub!"); }
111 
setGmtOffset(int gmtoff)112 public void setGmtOffset(int gmtoff) { throw new RuntimeException("Stub!"); }
113 
getYear()114 public int getYear() { throw new RuntimeException("Stub!"); }
115 
getMonth()116 public int getMonth() { throw new RuntimeException("Stub!"); }
117 
getMonthDay()118 public int getMonthDay() { throw new RuntimeException("Stub!"); }
119 
getHour()120 public int getHour() { throw new RuntimeException("Stub!"); }
121 
getMinute()122 public int getMinute() { throw new RuntimeException("Stub!"); }
123 
getSecond()124 public int getSecond() { throw new RuntimeException("Stub!"); }
125 
getWeekDay()126 public int getWeekDay() { throw new RuntimeException("Stub!"); }
127 
getYearDay()128 public int getYearDay() { throw new RuntimeException("Stub!"); }
129 
getGmtOffset()130 public int getGmtOffset() { throw new RuntimeException("Stub!"); }
131 
getIsDst()132 public int getIsDst() { throw new RuntimeException("Stub!"); }
133 }
134 
135