Exemple #1
0
        public string getShortTimeString(bool showDstIndicator, ref string dstIndicator)
        {
            bool     dst;
            DateTime dt;

            getLocalTimeEx(out dt, out dst);
            int h = dt.Hour;
            int m = dt.Minute + ((dt.Second > 30) ? 1 : 0);

            if (dstIndicator != null && getLocation().getTimeZone().isSupportDaylightSaving())
            {
                dstIndicator = GPAppHelper.GetDSTSignature(dst ? 1 : 0);
            }

            if (getLocation().getTimeZone().isSupportDaylightSaving() && showDstIndicator)
            {
                if (timeFormat24)
                {
                    return(string.Format("{0:00}:{1:00} ({2})", h, m, GPAppHelper.GetDSTSignature(dst ? 1 : 0)));
                }
                else
                {
                    return(string.Format("{0:00}:{1:00} {2} ({3})", (((h % 12) + 11) % 12 + 1), m, (h >= 12 ? "PM" : "AM"), GPAppHelper.GetDSTSignature(dst ? 1 : 0)));
                }
            }
            else
            {
                if (timeFormat24)
                {
                    return(string.Format("{0:00}:{1:00}", h, m));
                }
                else
                {
                    return(string.Format("{0:00}:{1:00} {2}", (((h % 12) + 11) % 12 + 1), m, (h >= 12 ? "PM" : "AM")));
                }
            }
        }
Exemple #2
0
 public string FormatTimeRange(int h1, int m1, int h2, int m2, bool dst)
 {
     if (timeFormat24)
     {
         if (getLocation().getTimeZone().isSupportDaylightSaving())
         {
             return(string.Format("{0:00}:{1:00} - {2:00}:{3:00} ({4})", h1, m1, h2, m2, GPAppHelper.GetDSTSignature(dst ? 1 : 0)));
         }
         else
         {
             return(string.Format("{0:00}:{1:00} - {2:00}:{3:00}", h1, m1, h2, m2));
         }
     }
     else
     {
         if (getLocation().getTimeZone().isSupportDaylightSaving())
         {
             return(string.Format("{0:00}:{1:00} {2} - {3:00}:{4:00} {5} ({6})", (((h1 % 12) + 11) % 12 + 1), m1, (h1 > 12), (((h2 % 12) + 11) % 12 + 1), m2, GPAppHelper.GetDSTSignature(dst ? 1 : 0)));
         }
         else
         {
             return(string.Format("{0:00}:{1:00} {2} - {3:00}:{4:00} {5}", (((h1 % 12) + 11) % 12 + 1), m1, (((h2 % 12) + 11) % 12 + 1), m2));
         }
     }
 }
Exemple #3
0
        public string getLongTimeString()
        {
            bool     dst;
            DateTime dt;

            getLocalTimeEx(out dt, out dst);
            if (getLocation().getTimeZone().isSupportDaylightSaving())
            {
                if (timeFormat24)
                {
                    return(string.Format("{0:00}:{1:00}:{2:00} ({3})", dt.Hour, dt.Minute, dt.Second, GPAppHelper.GetDSTSignature(dst ? 1 : 0)));
                }
                else
                {
                    return(string.Format("{0:00}:{1:00}:{2:00} {3} ({4})", (((dt.Hour % 12) + 11) % 12 + 1), dt.Minute, dt.Second, (dt.Hour >= 12 ? "PM" : "AM"), GPAppHelper.GetDSTSignature(dst ? 1 : 0)));
                }
            }
            else
            {
                if (timeFormat24)
                {
                    return(string.Format("{0:00}:{1:00}:{2:00}", dt.Hour, dt.Minute, dt.Second));
                }
                else
                {
                    return(string.Format("{0:00}:{1:00}:{2:00} {3}", (((dt.Hour % 12) + 11) % 12 + 1), dt.Minute, dt.Second, (dt.Hour >= 12 ? "PM" : "AM")));
                }
            }
        }