public static void GetDiffHours(DragBar T1, DragBar T2, bool min, out int diffhours, out int diffmins, out bool early, string fromTZ, string toTZ)
        {
            diffhours = diffmins = 0;

            var here = CustomTimeZones.FromString(fromTZ);

            var there = CustomTimeZones.FromString(toTZ);

            var TS1 = here.UTCoffset - there.UTCoffset;

            var wakeH = T1.BarMinimumValue;
            var wakeM = 0;

            var wakeH2 = T2.BarMinimumValue;
            var wakeM2 = 0;
            if (min == false)
            {
                wakeH = T1.BarMaximumValue;
                wakeH2 = T2.BarMaximumValue;
            }

            var a = 0;

            //option1
            while (wakeH != wakeH2 || wakeM != wakeM2)
            {
                if (wakeH > wakeH2)
                {
                    wakeH--;
                    diffhours--;
                }
                else if (wakeH < wakeH2)
                {
                    wakeH++;
                    diffhours++;
                }
                if (wakeM > wakeM2)
                {
                    wakeM -= 30;
                    diffmins -= 30;
                }
                else if (wakeM > wakeM2)
                {
                    wakeM += 30;
                    diffmins += 30;
                }
            }
            diffhours += TS1.Hours;
            diffmins += TS1.Minutes;
            diffhours %= 24;
            if (diffhours > 12)
            {
                diffhours = 24 - diffhours;
                early = true;
            }
            else if (diffhours < -12)
            {
                diffhours = 24 + diffhours;
                early = false;
            }
            else

                early = !(diffhours >= 0);// && diffmins >= 0);

            diffhours = Math.Abs(diffhours);
            diffmins = Math.Abs(diffmins);
        }
Exemplo n.º 2
0
 private void dragBar1_BarValueChange(DragBar entry)
 {
     SetT1Hours(entry.BarMaximumValue, entry.BarMinimumValue);
     GetOptions();
 }