Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4734668
  • 博文数量: 206
  • 博客积分: 5240
  • 博客等级: 大校
  • 技术积分: 3224
  • 用 户 组: 普通用户
  • 注册时间: 2010-08-12 21:40
文章分类

全部博文(206)

文章存档

2013年(13)

2012年(8)

2011年(33)

2010年(152)

我的朋友

分类: 系统运维

2012-08-12 20:12:35

import win.ui;
import inet.whttp
/*DSG{{*/
var winform = ..win.form( bottom=134;parent=...;right=301;text="取网站时间" )
winform.add( 
settimebn={ bottom=118;right=54;left=11;top=90;z=5;text=
"校正";cls="button" };
edit={ bottom=41;text=
"";left=22;top=17;z=2;right=282;edge=1;cls="edit" };
gettimebn={ bottom=80;right=55;left=12;top=52;z=4;text=
"获取";cls="button" };
groupbox={ bottom=49;right=292;left=10;top=3;z=1;text=
"网址";edge=1;cls="groupbox" };
edit2={ bottom=119;right=289;left=60;multiline=1;top=55;z=3;edge=1;cls=
"edit" }
)
/*}}*/

url = winform.edit.text
// 取网站时间
getTime = function(url){    
    
var whttp = inet.whttp()    
    whttp.beginRequest(url,
"GET")
    whttp.send()
    
var da = whttp.readHeader("Date")    
    
var tm=time(da,"%a,%d %b %Y %H:%M:%S");
    tm.addhour(8)
//GMT时间转北京时间    
    return tm;     
}

winform.edit.oncommand = 
function(id,event){
    
if(event==0x300/*_EN_CHANGE*/){//文本发生改变了
        url = winform.edit.text    
    }
}

 
// 获取网站时间 
winform.gettimebn.oncommand = function(id,event){           
    tm = getTime(url)
    tm.format=
"%H时%M分%S秒";
    tm1 = time(,
"%H时%M分%S秒")        
    winform.edit2.text = 
"网站时间:"+tostring(tm)+'\r\n'"本机时间:"+tostring(tm1)+'\r\n'    
}

//设置时间API 校正时间
SetLocalTime = ::Kernel32.api("SetLocalTime","int(struct lpSystemTime)")
winform.settimebn.oncommand = 
function(id,event){  
    
var tm = getTime(url)    
    SetLocalTime(tm);    
}

winform.show() 
win.loopMessage();


阅读(10468) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~