Date conversion using GMT
4 ビュー (過去 30 日間)
古いコメントを表示
I have a specific application in which I am reading in data into an array that includes a year (as an individual cell) and a GMT day. I need to convert the GMT day into an actual date using the year. If the year is in variable yr and GMT date in dGMT, I assumed that I could use the datestr function as follows:
d = datestr(addtodate(dGMT),floor(yr*365.25),'day'))
where datestr of the GMT returned the date in year 0000, and I simply add the amount of days that have elapsed since 1/1/0000. However, the data that is computed is off by about 2 weeks.
I did some investigating, and tried the above line of code with various years and dGMT=1.
I got the following: K>> datestr(addtodate((1),floor(1582*365.25),'day'))
ans =
31-Dec-1581
K>> datestr(addtodate((1),floor(1583*365.25),'day'))
ans =
10-Jan-1583
It seems that between year 1582 and 1583 10 days get added. Can anyone explain why, or possibly suggest another way to get the date?
0 件のコメント
回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Time Series Objects についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!