com.mhuss.AstroLib
Class TimeOps
- java.lang.Object
-
- com.mhuss.AstroLib.TimeOps
-
public class TimeOps extends java.lang.ObjectTimeOps contains miscellaneous time-related functions.
These are not in DateOps because they cause a circular dependancy between DateOps and AstroDate
-
-
Constructor Summary
Constructors Constructor and Description TimeOps()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static intdstOffset()Calculate the current Daylight Time offset.static intdstOffset(java.util.Calendar cal)Calculate the current Daylight Time offset ( 0 or -1 ).static doubledstOffsetInDays()Calculate the current Daylight Time offset in fractional days.static doubledstOffsetInDays(java.util.Calendar cal)Calculate the current Daylight Time offset in fractional days.static java.lang.StringformatTime(double t)Format a time as a String using the format HH:MM.static inttzOffset()Determine the absolute time zone offset from UTC in hours (-12 to +12) using the local timezone.static inttzOffset(java.util.Calendar cal)Determine the absolute time zone offset from UTC in hours (-12 to +12) for the spec'd Calendar.static doubletzOffsetInDays()Determine the absolute time zone offset from UTC in fractional days (-0.5 to +0.5).static doubletzOffsetInDays(java.util.Calendar cal)Determine the absolute time zone offset from UTC in fractional days (-0.5 to +0.5).
-
-
-
Method Detail
-
dstOffset
public static int dstOffset(java.util.Calendar cal)
Calculate the current Daylight Time offset ( 0 or -1 ).
Add the result of this function to the current time to adjust.- Parameters:
cal- A java.util.Calendar object which is used to get the DST_OFFSET from (e.g., java.util.GregorianCalendar)- Returns:
- DST_OFFSET in hours if Daylight time is in effect, 0 otherwise.
-
dstOffset
public static int dstOffset()
Calculate the current Daylight Time offset.
Add the result of this function to the current time to adjust.
This function uses a GregorianCalendar object.- Returns:
- DST_OFFSET in hours if Daylight time is in effect, 0 otherwise.
-
dstOffsetInDays
public static double dstOffsetInDays(java.util.Calendar cal)
Calculate the current Daylight Time offset in fractional days.
Add the result of this function to the current time to adjust.- Parameters:
cal- A java.util.Calendar object which is used to get the DST_OFFSET- Returns:
- DST_OFFSET in days if Daylight time is in effect, 0 otherwise.
-
dstOffsetInDays
public static double dstOffsetInDays()
Calculate the current Daylight Time offset in fractional days.
Add the result of this function to the current time to adjust.
This function uses a GregorianCalendar object.- Returns:
- DST_OFFSET in days if Daylight time is in effect, 0 otherwise.
-
tzOffset
public static int tzOffset(java.util.Calendar cal)
Determine the absolute time zone offset from UTC in hours (-12 to +12) for the spec'd Calendar.- Parameters:
cal- The Calendar to use- Returns:
- The offset in hours
-
tzOffset
public static int tzOffset()
Determine the absolute time zone offset from UTC in hours (-12 to +12) using the local timezone.- Returns:
- The offset in hours
-
tzOffsetInDays
public static double tzOffsetInDays(java.util.Calendar cal)
Determine the absolute time zone offset from UTC in fractional days (-0.5 to +0.5).- Parameters:
cal- The Calendar to use- Returns:
- The offset in decimal day
-
tzOffsetInDays
public static double tzOffsetInDays()
Determine the absolute time zone offset from UTC in fractional days (-0.5 to +0.5).- Returns:
- The offset in decimal day
-
formatTime
public static java.lang.String formatTime(double t)
Format a time as a String using the format HH:MM.
The returned string will be "--:--" if the time is INVALID.- Parameters:
t- The time to format in days- Returns:
- The formatted String
-
-
DMelt 3.0 © DataMelt by jWork.ORG