Example #1
0
        //public string ToString(DateTime datetime)
        //{
        //    // Add code
        //    return ToString();
        //}

        public string ToString()
        {
            string output = "";

            if (Year > 0)
            {
                output = Year.ToString();
                if (Month > 0 && Month < 13)
                {
                    output += dateSeparator + TwoDigitString(Month);
                    if (Date > 0 && Date < 32)
                    {
                        output += dateSeparator + TwoDigitString(Date);

                        // Time and can only be created with a full date
                        if (Hour > 0)
                        {
                            if (Hour > -1 && Hour < 24)
                            {
                                output += 'T' + TwoDigitString(Hour);
                                if (Minute > -1 && Minute < 60)
                                {
                                    output += timeSeparator + TwoDigitString(Minute);
                                    if (Second > -1 && Second < 61)
                                    {
                                        output += timeSeparator + TwoDigitString(Second);
                                        if (DecimalSecond > 0)
                                        {
                                            output += '.' + DecimalSecond.ToString();
                                        }
                                    }
                                }

                                // Time zone offset can only be created with a hour
                                if (TimeZoneSuffix != "")
                                {
                                    output += TimeZoneSuffix;
                                }

                                if (TimeZoneHour > 0)
                                {
                                    if (TimeZoneHour > -1 && TimeZoneHour < 24)
                                    {
                                        output += TwoDigitString(TimeZoneHour);
                                        if (TimeZoneMinute > -1 && TimeZoneMinute < 60)
                                        {
                                            output += timeSeparator + TimeZoneMinute;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(output);
        }
Example #2
0
        private int DecimalSecondToInt()
        {
            string output = DecimalSecond.ToString();

            output = output.Replace(".", "");
            int milsec = Convert.ToInt32(output);

            if (milsec > 999)
            {
                milsec = 999;
            }
            return(milsec);
        }
Example #3
0
        private string DecimalSecondToString()
        {
            string output = DecimalSecond.ToString();

            return(output.Replace("0.", ""));
        }