HandCoded.Finance.TimeZone.ToString C# (CSharp) Method

ToString() public method

Return a formatted represetation of the TimeZone. If the offset is zero this will be a 'Z' otherwise it will be '+HH:MM' or '-HH:MM'.
public ToString ( ) : string
return string
        public override string ToString()
        {
            if (offset == 0) return ("Z");

            lock (buffer) {
                int 				value;

                buffer.Length = 0;

                if (offset < 0) {
                    buffer.Append ('-');
                    value = -offset;
                }
                else {
                    buffer.Append ('+');
                    value =  offset;
                }

                int hours 	= value / 60;
                int minutes = value % 60;

                buffer.Append ((char)('0' + hours / 10));
                buffer.Append ((char)('0' + hours % 10));
                buffer.Append (':');
                buffer.Append ((char)('0' + minutes / 10));
                buffer.Append ((char)('0' + minutes % 10));

                return (buffer.ToString ());
            }
        }