求一段火车头C#时间的数据处理代码
一标签采集出来的结果是1H2M4S这样的时间格式,H=小时,M=分钟,S=秒想把这个时间计算成秒
比如1H2M4S转化成3724
不胜感激!
using System;
using System.Collections.Generic;
using SpiderInterface;
class LocoyCode{
public string Run(string content,ResponseEntry response){
string timeStamp = content;
DateTime newTime;
DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime);
newTime = dateTimeStart.Add(toNow);
content = newTime.ToString("yyyy-MM-dd HH:mm:ss");
return content;
}
}
using System;
using System.Collections.Generic;
using SpiderInterface;
class LocoyCode{
public string Run(string content,ResponseEntry response){
string timeStamp = content;
DateTime newTime;
DateTime dateTimeStart = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
long lTime = long.Parse(timeStamp + "0000000");
TimeSpan toNow = new TimeSpan(lTime);
newTime = dateTimeStart.Add(toNow);
content = newTime.ToString("yyyy-MM-dd HH:mm:ss");
return content;
}
}
页:
[1]