Ejemplo n.º 1
0
        public static String GetSuperShortTime(DateTime dt)
        {
            if (formatInfo_GetSuperShortTime == null)
            {
                lock (lock_GetSuperShortTime)
                {
                    StringBuilder result = new StringBuilder(String.Empty);
                    String        seconds;

                    formatInfo_GetSuperShortTime = (DateTimeFormatInfo)CultureInfo.CurrentCulture.DateTimeFormat.Clone();

                    result.Append(formatInfo_GetSuperShortTime.LongTimePattern);
                    seconds = rxSeconds.Match(result.ToString()).Value;
                    result.Replace(" ", String.Empty);
                    result.Replace(seconds, String.Empty);
                    if (!(DateTimeFormatHelper.IsCurrentCultureJapanese() ||
                          DateTimeFormatHelper.IsCurrentCultureKorean() ||
                          DateTimeFormatHelper.IsCurrentCultureHungarian()))
                    {
                        result.Replace(DoubleMeridiemDesignator, SingleMeridiemDesignator);
                    }

                    formatInfo_GetSuperShortTime.ShortTimePattern = result.ToString();
                }
            }

            return(dt.ToString("t", formatInfo_GetSuperShortTime).ToLowerInvariant());
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the abbreviated day from a
 /// <see cref="T:System.DateTime"/>
 /// object.
 /// </summary>
 /// <param name="dt">Date information.</param>
 /// <returns>e.g. "Mon" for Monday when en-US.</returns>
 public static String GetAbbreviatedDay(DateTime dt)
 {
     if (DateTimeFormatHelper.IsCurrentCultureJapanese() || DateTimeFormatHelper.IsCurrentCultureKorean())
     {
         return("(" + dt.ToString("ddd", CultureInfo.CurrentCulture) + ")");
     }
     else
     {
         return(dt.ToString("ddd", CultureInfo.CurrentCulture));
     }
 }