1 /**
2 * Copyright 2004-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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 package org.kuali.hr.time.timezone.service;
17
18 import java.util.List;
19
20 import org.joda.time.DateTimeZone;
21 import org.kuali.hr.core.KPMEConstants;
22 import org.kuali.hr.time.timeblock.TimeBlock;
23 import org.springframework.cache.annotation.Cacheable;
24
25 public interface TimezoneService {
26
27 /**
28 * Returns the DateTimeZone object for the current user OR the system
29 * default timezone if there is no current user / a time zone is missing.
30 *
31 * @return
32 */
33 public DateTimeZone getUserTimezoneWithFallback();
34
35 /**
36 * Fetch user time zone of the current on-context user.
37 * @return
38 */
39 public String getUserTimezone();
40
41 /**
42 * (this call may be cached)
43 * Fetch the users timezone, Data on:
44 *
45 * Principal Calendar > Job/Location > System Default
46 *
47 * @param principalId The principal you are looking for.
48 *
49 * @return String timezone, see: http://joda-time.sourceforge.net/timezones.html
50 */
51 @Cacheable(value= KPMEConstants.KPME_GLOBAL_CACHE_NAME, key="'{UserTimezone}' + 'principalId=' + #p0")
52 public String getUserTimezone(String principalId);
53
54 /**
55 * Translate TimeBlocks to a given timezone
56 * @param timeBlocks
57 * @param timezone
58 * @return
59 */
60 public List<TimeBlock> translateForTimezone(List<TimeBlock> timeBlocks, String timezone);
61
62 public void translateForTimezone(List<TimeBlock> timeBlocks);
63
64 /**
65 * Determine if Timezone is same as server timezone
66 * @return
67 */
68 public boolean isSameTimezone();
69
70 public long getTimezoneOffsetFromServerTime(DateTimeZone dtz);
71 }