예제 #1
0
        public static string GetSuperShortTime(DateTime dt)
        {
            if (_formatInfoGetSuperShortTime == null)
            {
                lock (LockGetSuperShortTime)
                {
                    StringBuilder result = new StringBuilder(string.Empty);
                    string seconds;

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

                    result.Append(_formatInfoGetSuperShortTime.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);
                    }

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

            return dt.ToString("t", _formatInfoGetSuperShortTime).ToLowerInvariant();
        }
예제 #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);
     }
 }