BDS
(1)北斗系统的时间基准为北斗时(BDT)。
(2)BDT采用国际单位制(SI)秒为基本单位连续累计,不闰秒,起始历元为2006年1月1日协调世界时(UTC)00时00分00秒,采用周和周内秒计数。
(3)BDT通过UTC(NTSC)与国际UTC建立联系,BDT与UTC的偏差保持在100纳秒以内(模1秒)。
(4)BDT与UTC之间的闰秒信息在导航电文中播报,至2017年底该差值为4s。
1.BDS周-周内秒与日历时的转换与逆转换
1.1 BDS周-周内秒到年月日时间系统的转换
static private DateTime bds_WeekWIS_NYR(int bdsWeek, int bdsWIS)
{
//计算每周的秒数
int difFromBegin = bdsWeek * 604800 + bdsWIS;
//BDT采用国际单位制(SI)秒为基本单位连续累计,不闰秒,起始历元为2006年1月1日协调世界时(UTC)00时00分00秒,采用周和周内秒计数。
DateTime bdsBeginTime = new DateTime(2006, 1, 1, 0, 0, 0);
//将指定的秒数添加至初始时间
return bdsBeginTime.AddSeconds(difFromBegin);
}
1.2 年月日时间系统到BDS周-周内秒的转换
static private int[] bds_NYR_WeekWIS(DateTime bdsNYR)
{
//BDS时间系统的初始时间
DateTime bdsBeginUTC = new DateTime(2006, 1, 1, 0, 0, 0);
//计算当前时间与BDS起始时刻时间差
TimeSpan interval = bdsNYR - bdsBeginUTC;
int[] bdsWeekWIS = { 0, 0 };
//计算周
int bdsWeek = (int)interval.TotalSeconds / 604800;
//计算周内秒
int bdsWIS = (int)interval.TotalSeconds % 604800;
bdsWeekWIS[0] = bdsWeek;
bdsWeekWIS[1] = bdsWIS;
return bdsWeekWIS;
}
1.3 主函数调用
static void Main(string[] args)
{
int[] bdsWeekWIS = { 667, 431986 };
Console.WriteLine("北斗周:{0:D},周内秒: {1:D}", bdsWeekWIS[0], bdsWeekWIS[1]);
Console.WriteLine("-----------------------------------------");
//===1.BDS周-周内秒与日历时的转换与逆转换===
Console.Write("BDS 周-周内秒 <-> 日历时:");
Console.WriteLine(bds_WeekWIS_NYR(bdsWeekWIS[0], bdsWeekWIS[1]));
Console.Write("BDS 年月日 <-> 周-周内秒:");
DateTime bdsNYR = new DateTime(2018, 10, 18, 23, 59, 46);
int[] bdsWeekWISFrombdsNYR = bds_NYR_WeekWIS(bdsNYR);
Console.WriteLine("bds周:{0:D},周内秒:{1:D}", bdsWeekWISFrombdsNYR[0], bdsWeekWISFrombdsNYR[1]);
Console.WriteLine("-----------------------------------------");
Console.ReadLine();
}
1.4 运行结果
2.BDS周-周内秒与UTC时间系统的转换与逆转换
2.1 BDS周-周内秒到UTC时间系统的转换
static private DateTime bds_WeekWIS_NYR(int bdsWeek, int bdsWIS)
{
//计算每周的秒数
int difFromBegin = bdsWeek * 604800 + bdsWIS;
//BDT采用国际单位制(SI)秒为基本单位连续累计,不闰秒,起始历元为2006年1月1日协调世界时(UTC)00时00分00秒,采用周和周内秒计数。
DateTime bdsBeginTime = new DateTime(2006, 1, 1, 0, 0, 0);
//将指定的秒数添加至初始时间
return bdsBeginTime.AddSeconds(difFromBegin);
}
static private DateTime bds_WeekWIS_UTC(int bdsWeek, int bdsWIS)
{
//获取日历时
DateTime bdsNYR = bds_WeekWIS_NYR(bdsWeek, bdsWIS);
//BDS日历时比UTC时快4秒
return bdsNYR.AddSeconds(-4.0);
}
2.2 UTC时间系统到BDS周-周内秒的转换
static private int[] bds_NYR_WeekWIS(DateTime bdsNYR)
{
//BDS时间系统的初始时间
DateTime bdsBeginUTC = new DateTime(2006, 1, 1, 0, 0, 0);
//计算当前时间与BDS起始时刻时间差
TimeSpan interval = bdsNYR - bdsBeginUTC;
int[] bdsWeekWIS = { 0, 0 };
//计算周
int bdsWeek = (int)interval.TotalSeconds / 604800;
//计算周内秒
int bdsWIS = (int)interval.TotalSeconds % 604800;
bdsWeekWIS[0] = bdsWeek;
bdsWeekWIS[1] = bdsWIS;
return bdsWeekWIS;
}
static private int[] bds_UTC_WeekWIS(DateTime bdsUTC)
{
//将UTC对应的日历时,解算出周-周内秒
return bds_NYR_WeekWIS(bdsUTC.AddSeconds(4));
}
2.3 主函数调用
static void Main(string[] args)
{
int[] bdsWeekWIS = { 667, 431986 };
Console.WriteLine("北斗周:{0:D},周内秒: {1:D}", bdsWeekWIS[0], bdsWeekWIS[1]);
Console.WriteLine("-----------------------------------------");
//===2.BDS周-周内秒与UTC时间系统的转换与逆转换===
Console.Write("BDS 周-周内秒 <-> UTC时:");
Console.WriteLine(bds_WeekWIS_UTC(bdsWeekWIS[0], bdsWeekWIS[1]));
Console.Write("BDS UTC <-> 周-周内秒:");
DateTime bdsUTC = new DateTime(2018, 10, 18, 23, 59, 42);
int[] bdsWeekWISFrombdsUTC = bds_UTC_WeekWIS(bdsUTC);
Console.WriteLine("bds周:{0:D},周内秒:{1:D}", bdsWeekWISFrombdsUTC[0], bdsWeekWISFrombdsUTC[1]);
Console.WriteLine("-----------------------------------------");
Console.ReadLine();
}