Exemple #1
0
        ///<Summary>
        /// Converts a time to a string using the Win32 API which correctly handles
        /// locale customization. (The default .NET APIs take only the base user locale
        /// and ignore the customizations.)
        ///</Summary>
        private static string TimeToStringWin32(DateTime dt)
        {
            SYSTEMTIME st = new SYSTEMTIME();

            st.Hour   = (short)dt.Hour;
            st.Minute = (short)dt.Minute;
            lock ( _timeStringBuilder )
            {
                _timeStringBuilder.Length = 0;
                Win32Declarations.GetTimeFormat(Win32Declarations.LOCALE_USER_DEFAULT,
                                                Win32Declarations.TIME_NOSECONDS, ref st, null, _timeStringBuilder, 255);
                return(_timeStringBuilder.ToString());
            }
        }