/*
  * internal static void LocalDateTime(this Label textbox)
  * {
  *  textbox.LocalDateTime(DateTime.Now.ToLocalTime(), DateOutputPart.ALL);
  * }
  *
  * internal static void LocalDateTime(this Label textbox, DateOutputPart part = DateOutputPart.ALL)
  * {
  *  textbox.LocalDateTime(DateTime.Now.ToLocalTime(), part);
  * }
  */
 internal static void LocalDateTime(this Label textbox, DateTime date, DateOutputPart output = DateOutputPart.ALL)
 {
     if (textbox == null)
     {
         return;
     }
     textbox.Text = Function.ToLocalDateString(date, output);
 }
Example #2
0
        internal static String DateFormatForPart(DateOutputPart part)
        {
            switch (part)
            {
            case DateOutputPart.DATE: return("d");

            case DateOutputPart.TIME: return("t");

            case DateOutputPart.ISO: return("o");

            default: return("g");
            }
        }
Example #3
0
        internal static String ToLocalDateString(String date, DateOutputPart input = DateOutputPart.ALL, DateOutputPart output = DateOutputPart.ALL)
        {
            DateTime parsed;

            if (DateTime.TryParseExact(date, DateFormatForPart(input), CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out parsed))
            {
                return(ToLocalDateString(parsed, output));
            }
            else
            {
                return(date);
            }
        }
Example #4
0
        internal static String ToLocalTimeString(this DateTime date, DateOutputPart output = DateOutputPart.ALL)
        {
            var local = date.ToLocalTime();

            switch (output)
            {
            case DateOutputPart.DATE: return(local.ToShortDateString());

            case DateOutputPart.TIME: return(local.ToShortTimeString());

            case DateOutputPart.ISO: return(local.ToString("g"));

            default: return(local.ToString("f"));
            }
        }
        internal static void LocalDateTime(this Label textbox, String dateTime, DateOutputPart input = DateOutputPart.ALL, DateOutputPart output = DateOutputPart.ALL)
        {
            if (textbox == null)
            {
                return;
            }
            DateTime parsed;

            if (DateTime.TryParseExact(dateTime, Function.DateFormatForPart(input), CultureInfo.CurrentCulture, DateTimeStyles.AssumeLocal, out parsed))
            {
                textbox.LocalDateTime(parsed, output);
            }
            else
            {
                textbox.SetText(dateTime);
            }
        }
Example #6
0
        internal static String ToLocalDateString(DateTime date, DateOutputPart output, bool convertToLocal = true)
        {
            var local = date;

            if (convertToLocal)
            {
                local = date.ToLocalTime();
            }
            switch (output)
            {
            case DateOutputPart.DATE: return(local.ToShortDateString());

            case DateOutputPart.TIME: return(local.ToShortTimeString());

            case DateOutputPart.ISO: return(local.ToString("g"));

            default: return(local.ToString("f"));
            }
        }
 internal static String ToLocalTimeString(this DateTime date, DateOutputPart output = DateOutputPart.ALL)
 {
     return(date.ToDateTimeString(output, true));
 }
Example #8
0
 internal static void LocalDateTime(this Label textbox, DateOutputPart part = DateOutputPart.ALL)
 {
     textbox.LocalDateTime(DateTime.Now.ToLocalTime(), part);
 }