<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic 回复： How does this binary file restore the correct time of year, month and day? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-does-this-binary-file-restore-the-correct-time-of-year-month/m-p/594627#M79849</link>
    <description>&lt;P&gt;&lt;SPAN&gt;The date and time at the beginning of line 4 should be :&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;20230120 15:00&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;bb = Load Text File( "123.DAT", blob() );

z = Length( bb ) / 56;
For( k = 1, k &amp;lt;= z, k++,
	a = Blob Peek( bb, (k - 1) * 56, 56 );
	y = Blob To Matrix( a, "uint", 2, "little", 28 );
	s = Blob To Matrix( a, "uint", 4, "little", 28 );
	b = Blob To Matrix( a, "uint", 4, "little", 28 );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 29 Jan 2023 14:05:35 GMT</pubDate>
    <dc:creator>lala</dc:creator>
    <dc:date>2023-01-29T14:05:35Z</dc:date>
    <item>
      <title>How does this binary file restore the correct time of year, month and day?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-this-binary-file-restore-the-correct-time-of-year-month/m-p/594607#M79847</link>
      <description>&lt;P&gt;This file has four lines of data, and the first eight bytes of each line are the year, month, and day data&lt;BR /&gt;How to make a table correctly with JSL?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2023-01-29_21-49-08.png" style="width: 834px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49587i4F388FB1678D5B83/image-size/large?v=v2&amp;amp;px=999" role="button" title="2023-01-29_21-49-08.png" alt="2023-01-29_21-49-08.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Jun 2023 16:40:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-this-binary-file-restore-the-correct-time-of-year-month/m-p/594607#M79847</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-06-08T16:40:05Z</dc:date>
    </item>
    <item>
      <title>回复： How does this binary file restore the correct time of year, month and day?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-this-binary-file-restore-the-correct-time-of-year-month/m-p/594627#M79849</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The date and time at the beginning of line 4 should be :&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;20230120 15:00&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;bb = Load Text File( "123.DAT", blob() );

z = Length( bb ) / 56;
For( k = 1, k &amp;lt;= z, k++,
	a = Blob Peek( bb, (k - 1) * 56, 56 );
	y = Blob To Matrix( a, "uint", 2, "little", 28 );
	s = Blob To Matrix( a, "uint", 4, "little", 28 );
	b = Blob To Matrix( a, "uint", 4, "little", 28 );
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Jan 2023 14:05:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-this-binary-file-restore-the-correct-time-of-year-month/m-p/594627#M79849</guid>
      <dc:creator>lala</dc:creator>
      <dc:date>2023-01-29T14:05:35Z</dc:date>
    </item>
    <item>
      <title>回复： How does this binary file restore the correct time of year, month and day?</title>
      <link>https://community.jmp.com/t5/Discussions/How-does-this-binary-file-restore-the-correct-time-of-year-month/m-p/598272#M80189</link>
      <description>&lt;P&gt;You've got two big hints in the work you've already done: an actual date, and the code &lt;EM&gt;time_t&lt;/EM&gt;. Time_t is a Unix thing. Lets try a tool like epoch converter, and push the date you know into it:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="the red number is what we want" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/49914i6CAD44F8873F0C89/image-size/large?v=v2&amp;amp;px=999" role="button" title="capture.png" alt="the red number is what we want" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;the red number is what we want&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Hey! that number also appears in your data inspector! It is an int 32! That means we can load your data like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;za = Open( "z:/123.zip", zip );
blob = za &amp;lt;&amp;lt; read( "123.dat", Format( blob ) );
dates = Blob To Matrix( blob, "int", 4, "little", 14 )[0, 1];

dates += 1jan1970;
For( i = 1, i &amp;lt;= 4, i += 1,
	Show( i, As Date( dates[i] ) )
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;STRONG&gt;i = 1;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;As Date(dates[i]) = 20Jan2023:06:56:00;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;i = 2;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;As Date(dates[i]) = 20Jan2023:06:57:00;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;i = 3;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;As Date(dates[i]) = 20Jan2023:06:58:00;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;i = 4;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;As Date(dates[i]) = 20Jan2023:07:00:00;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The Unix epoch begins on 1Jan1970, which is 0. The JMP epoch begins on 1Jan1904, which is 0. Adding JMP's 1Jan1970 value to a Unix date converts the Unix date to a JMP date.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The blob to matrix call makes 14 4-byte numbers per row; the subscript [0,1] means 0: keep all 4 rows and 1: keep the first element on each row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;While you are playing with the epoch converter, try some dates in 2038. 2038 is the year of the next two Y2K-like events. Yes, there are two issues in one year. The first one is the &lt;A href="https://en.wikipedia.org/wiki/Year_2038_problem" target="_blank" rel="noopener"&gt;Epochalypse&lt;/A&gt; at 03:14:07&amp;nbsp;UTC on 19&amp;nbsp;January&amp;nbsp;2038. The second one is the third &lt;A href="https://en.wikipedia.org/wiki/GPS_week_number_rollover" target="_blank" rel="noopener"&gt;GPS week roll over&lt;/A&gt;, which will probably go unnoticed. The third rollover will occur between November 20 and 21, 2038.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 00:48:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-does-this-binary-file-restore-the-correct-time-of-year-month/m-p/598272#M80189</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2023-02-08T00:48:12Z</dc:date>
    </item>
  </channel>
</rss>

