Ejemplo n.º 1
0
 //this method returns timezoneinfo for a specific time zone name for the current UTC time.
 //if no equivalent time zone is found, null is returned.
 public TimeZoneCustom GetTimeZoneInfo(string TimeZoneName, bool CaterForDST)
 {
     //get a list of all the timezone definitions
     foreach (TimeZoneInfo tzi in TimeZoneInfo.GetSystemTimeZones())
     {
         if (string.Compare(TimeZoneName, tzi.StandardName, true) == 0 || (string.Compare(TimeZoneName, tzi.DaylightName, true) == 0))
         {
             TimeZoneCustom tz = new TimeZoneCustom(BaseTime, tzi, CaterForDST);
             return(tz);
         }
     }
     return(null);
 }
Ejemplo n.º 2
0
        //internal method to return a collection of Time Zones
        public TimeZoneCustom[] GetTimeZonesInfo(bool CaterForDST)
        {
            List <TimeZoneCustom> timeZones = new List <TimeZoneCustom>();

            DateTime currentTimeUTC = BaseTime.ToUniversalTime();

            //get a list of all the timezone definitions
            foreach (TimeZoneInfo tzi in TimeZoneInfo.GetSystemTimeZones())
            {
                TimeZoneCustom tz = new TimeZoneCustom(BaseTime, tzi, CaterForDST);
                timeZones.Add(tz);
            }
            return(timeZones.ToArray());
        }
Ejemplo n.º 3
0
        //this method returns timezoneinfo for a specific date time. We assume that the datetime has already been converted to UTC
        public TimeZoneCustom[] GetTimeZonesInfoForSpecificUTCDate(DateTime targetDateTime, bool CaterForDST)
        {
            List <TimeZoneCustom> timeZones = new List <TimeZoneCustom>();

            this.BaseTime = targetDateTime;

            //get a list of all the timezone definitions
            foreach (TimeZoneInfo tzi in TimeZoneInfo.GetSystemTimeZones())
            {
                TimeZoneCustom tz = new TimeZoneCustom(BaseTime, tzi, CaterForDST);
                timeZones.Add(tz);
            }
            return(timeZones.ToArray());
        }
Ejemplo n.º 4
0
        public TimeZoneCustom ReadTimeZone()
        {
            TimeZoneCustom tz = null;
            //retrieve the value of the time zone input property by querying the same property of the class.
            //behind the scenes K2 will set the properties for the class based on the input parameters provided by the user.
            string tzName = Name;

            //we'll check if the field is blank or empty, even through it is required and should therefore never be blank
            if (string.IsNullOrEmpty(tzName))
            {
                throw new Exception("Time Zone Name is required");
            }

            tz = GetTimeZoneInfo(tzName, _caterForDST);

            return(tz);
        }