using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChamChat.Models
{
    public static class ExtensionMethods
    {

        public static String GetTags(this String XML, String Tag)
        {
            try
            {
                int i1 = XML.IndexOf("<" + Tag + ">") + Tag.Length + 2;
                int i2 = XML.IndexOf("</" + Tag + ">");
                return XML.Substring(i1, i2 - i1);
            }
            catch
            {
                return "";
            }
        }


        public static String ToHex(this byte Dec)
        {
            return  Dec.ToString("X").PadLeft(2,'0');
        }


        //public static Int32[] HrsMinSecFromMinutes(this double Minutes)
        //{
        //    int[] result = new int[3];

        //    int hrs = (int)Math.Floor(Minutes / 60);
        //    double left = Minutes - 60 * (double)hrs;
        //    int min = (int)Math.Floor(left / 60);
        //    left -= (double)min;
        //    int sec = (int)Math.Floor(left * 60);
        //    return result;
        //}


    }
}
