{"id":990,"date":"2010-03-27T20:40:00","date_gmt":"2010-03-27T12:40:00","guid":{"rendered":""},"modified":"2013-11-17T16:01:23","modified_gmt":"2013-11-17T08:01:23","slug":"gps%e6%97%b6%e4%b8%8e%e6%a0%bc%e9%87%8c%e9%ab%98%e5%88%a9%e5%8e%86%e8%bd%ac%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/990.html","title":{"rendered":"GPS\u65f6\u4e0e\u683c\u91cc\u9ad8\u5229\u5386\u8f6c\u6362"},"content":{"rendered":"<p>\u683c\u91cc\u9ad8\u5229\u5386\u5c31\u662f\u6211\u4eec\u5e73\u65f6\u7528\u7684\u5e74\u6708\u65e5\u7684\u4e1c\u897f\u3002<\/p>\n<pre class=\"brush: delphi; title: ; notranslate\" title=\"\">\r\nunit gpstime;\r\n\r\ninterface\r\n\r\nuses\r\n  SysUtils,Math;\r\n\r\nprocedure GPSToGer(week: integer; seconds: Extended; var year,month,day,dayofweek,hour,minute,second: Integer);\r\nprocedure GerToGPS(year,month,day,hour,minute: Integer; seconds: Extended; var weekno: Integer; var gpstime: Extended);\r\n\r\nimplementation\r\n\/\/GPS\u65f6\u95f4\u8f6c\u6362\u4e3a\u683c\u6797\u9ad8\u5386(\u666e\u901a\u7684\u65e5\u5386)\r\nprocedure GPSToGer(week: integer; seconds: Extended; var year,month,day,dayofweek,hour,minute,second: Integer);\r\nvar JD: Extended;\r\n    a: Integer;\r\n    b,c,d,e: Integer;\r\nbegin\r\n  if(week &lt; 1024) then week := week+1024;\r\n  JD := week*7+seconds\/86400+2444244.5;\r\n  a := Trunc(JD+0.5);\r\n  b := a+1537;\r\n  c := Trunc((b-122.1)\/365.25);\r\n  d := Trunc(365.25*c);\r\n  e := Trunc((b-d)\/30.6001);\r\n  day := Trunc( b-d-Trunc(30.6001*e)+Frac(JD+0.5) );\r\n  month := e-1-12*Trunc(e\/14);\r\n  year := c-4715-Trunc((7+month)\/10);\r\n  dayofweek := Trunc(JD+0.5) mod 7;        \/\/\u661f\u65af\u51e0\uff0c0\u4e3a\u4e00\uff0c6\u4e3a\u5468\u65e5\r\n  a := Trunc(seconds) mod 86400;\r\n  hour := a div 3600;\r\n  minute := (a mod 3600) div 60;\r\n  second := a mod 60;\r\nend;\r\n\/\/\u683c\u6797\u9ad8\u5386(\u666e\u901a\u7684\u65e5\u5386)\u8f6c\u6362\u4e3aGPS\u65f6\u95f4\r\nprocedure GerToGPS(year,month,day,hour,minute: Integer; seconds: Extended; var weekno: Integer; var gpstime: Extended);\r\nvar dayofw, dayofy, yr, ttlday, m: Integer;\r\nconst dinmth: array&#x5B;0..12] of integer=(0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);\r\nbegin\r\n  if (year &lt; 1981) or  (month &lt; 1) or (month &gt; 12) or (day &lt; 1) or (day &gt; 31) then weekno := 0;\r\n  if(month=1) then dayofy := day\r\n  else\r\n  begin\r\n    dayofy := 0;\r\n    for m := 1 to month - 1 do\r\n      begin\r\n        dayofy := dayofy+dinmth&#x5B;m];\r\n        if(m=2) then\r\n        begin\r\n          if((year mod 4=0) and (year mod 100&lt;&gt;0)) or (year mod 400=0) then\r\n          dayofy := dayofy+1;\r\n        end;\r\n      end;\r\n    dayofy := dayofy+day;\r\n  end;\r\n  ttlday := 360;\r\n  for yr := 1981 to year - 1 do\r\n  begin\r\n    ttlday := ttlday+365;\r\n    if((yr mod 4=0) and (yr mod 100&lt;&gt;0)) or (yr mod 400=0) then\r\n    ttlday := ttlday+1;\r\n  end;\r\n  ttlday := ttlday+dayofy;\r\n  weekno := ttlday div 7;\r\n  dayofw := ttlday-7*weekno;\r\n  gpstime := (hour * 3600 + minute * 60 + seconds + dayofw * 86400);\r\n  if(weekno&gt;1024) then weekno := weekno-1024;\r\nend;\r\n\r\nend.\r\n<\/pre>\n<p>\u8f6f\u4ef6\u622a\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" src=\".\/wp-content\/uploads\/hibaidu\/b0c75f3c06980fd83d6d97e0.jpg\" alt=\"\" border=\"0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u683c\u91cc\u9ad8\u5229\u5386\u5c31\u662f\u6211\u4eec\u5e73\u65f6\u7528\u7684\u5e74\u6708\u65e5\u7684\u4e1c\u897f\u3002 unit gpstime; interface uses SysUt [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-990","post","type-post","status-publish","format-standard","hentry","category-diary"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=990"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/990\/revisions"}],"predecessor-version":[{"id":4647,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/990\/revisions\/4647"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=990"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=990"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}