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

namespace FObjBase
{
    public class Converter
    {
        public static string BytesToString(byte[] bytes)
        {
            return System.Text.Encoding.UTF8.GetString(bytes);
        }
        public static string BytesToString(byte[] bytes, int index, int count) 
        {
            return System.Text.Encoding.UTF8.GetString(bytes, index, count);
        }
        public static byte[] StringToBytes(string str)
        {
            return System.Text.Encoding.UTF8.GetBytes(str);
        }
        public static string DateTimeToString(DateTime dt)
        {
            return dt.ToString();
        }
        public static UInt32 DateTime2Time_T(DateTime dt)
        {
            return (UInt32)dt.Subtract(DateTime.Parse("01/01/1970")).TotalSeconds;
        }
        public static DateTime Time_T2DateTime(UInt32 time_t)
        {
            return DateTime.Parse("01/01/1970").AddSeconds(time_t);
        }
    }
}
