首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

请教:怎么将UNIX时间化为当前系统时间?(注一个UNIX时间为4个字节)谁可以转化一下

2011-12-29 
请问:如何将UNIX时间化为当前系统时间?(注一个UNIX时间为4个字节)哪位高手可以转化一下#includemy.h DWO

请问:如何将UNIX时间化为当前系统时间?(注一个UNIX时间为4个字节)哪位高手可以转化一下
#include   "my.h "

DWORD   GetUnixt(void);
void   GetHext(DWORD   ASECOND);

extern   CLOCK   Clock;
const   BYTE   s365[12]={31,28,31,30,31,30,31,31,30,31,30,31,};
const   BYTE   s366[12]={31,29,31,30,31,30,31,31,30,31,30,31,};

//由实时时钟得到UNIX时钟
DWORD   GetUnixt(void)
{
                DWORD   temp;
                WORD   temp0=0,temp1=0,temp2;
                BYTE   *ptr,i;

                for(i=0;i <Clock.year;i++)
                {
                                if(i%4==0)temp2=366;
                                else   temp2=365;
                                temp0+=temp2;
                }
                if(Clock.year%4==0)ptr=(void*)&s366;
                else   ptr=(void*)&s365;
                for(i=0;i <(Clock.month-1);i++)temp1+=(WORD)*ptr++;
                temp0=temp0+temp1+Clock.day-1;
                temp=(UDWORD)temp0*24;
                temp+=Clock.hour;
                temp*=60;
                temp+=Clock.minute;
                temp*=60;
                return(temp+Clock.second);
}

//由UNIX时钟得到实时时钟
void   GetHext(DWORD   ASECOND)
{
                BYTE   i=0,*ptr;
                DWORD   temp0,temp1;

                temp0=ASECOND/86400;
                temp1=ASECOND%86400;
                Clock.second=temp1%60;
                Clock.minute=(temp1/60)%60;
                Clock.hour=temp1/3600;
                temp1=366;
                while(temp0> temp1)
                {
                                if(i%4==0)temp1=366;
                                else   temp1=365;
                                temp0-=temp1;
                                i++;
                }


                Clock.year=i;
                if(i%4==0)ptr=(void*)&s366;
                else   ptr=(void*)&s365;
                i=1;
                while(temp0> =*ptr)
                {
                                temp0-=*ptr++;
                                i++;
                }
                Clock.month=i;
                Clock.day=temp0+1;
}


以上是C语言,,UNIX时间化为当前系统时间
请问如何将其转变为C#的呢,,
谢谢各位,,帮帮忙

[解决办法]
四个字节你用计算器算下就是一个long ticks 自己写代码转了

热点排行