Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows timestamp in converter panel #114

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/ui/Components/ConverterPanel.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
<tr><td>float</td> <td colspan="2">{{model.float }}</td></tr>
<tr><td>double</td> <td colspan="2">{{model.double}}</td></tr>
<tr><td>unixts</td> <td colspan="2">{{model.unixts}}</td></tr>
<tr><td>wints</td> <td colspan="2">{{model.wints}}</td></tr>
<tr><td>ascii</td> <td colspan="2"><div class="str">{{model.ascii }}</div></td></tr>
<tr><td>utf8</td> <td colspan="2"><div class="str">{{model.utf8 }}</div></td></tr>
<tr><td>utf16le</td><td colspan="2"><div class="str">{{model.utf16le}}</div></td></tr>
<tr><td>utf16be</td><td colspan="2"><div class="str">{{model.utf16be}}</div></td></tr>
</table>
</div>
</template>
</template>
12 changes: 12 additions & 0 deletions src/ui/Components/ConverterPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ export class Converter {
return str.substring(0, i);
return str + "...";
}

static unixToWinTs(wints: int): int {
GreyCat marked this conversation as resolved.
Show resolved Hide resolved
var unixEpoch = new Date(1970, 1, 1).getTime()
var winEpoch = new Date(1601, 1, 1).getTime()
var epochDeltaInSec = (unixEpoch - winEpoch) / 1_000
var winTsInSec = wints / 10_000_000
return winTsInSec - epochDeltaInSec
}
}

export class ConverterPanelModel {
Expand All @@ -48,6 +56,7 @@ export class ConverterPanelModel {
float: string = "";
double: string = "";
unixts: string = "";
wints: string = "";
ascii: string = "";
utf8: string = "";
utf16le: string = "";
Expand Down Expand Up @@ -75,6 +84,9 @@ export class ConverterPanelModel {
var u32le = Converter.numConv(data, 4, false, false);
this.unixts = u32le ? dateFormat(new Date(parseInt(u32le) * 1000), "yyyy-mm-dd HH:MM:ss") : "";

var u64le = Converter.numConv(data, 8, false, false);
this.wints = u64le ? dateFormat(new Date(Converter.unixToWinTs(parseInt(u64le)) * 1000), "yyyy-mm-dd HH:MM:ss") : "";

try {
this.ascii = Converter.strDecode(data, "ascii");
this.utf8 = Converter.strDecode(data, "utf-8");
Expand Down