Created with <3 with dartpad.dev.
Created
September 10, 2022 08:07
-
-
Save Roms1383/bdde0114867f4a6765a0924938a7e718 to your computer and use it in GitHub Desktop.
using DateTime constructor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print('equivalent in Rust: 1974-10-04 20:39:12.153154 UTC (ms 150151152153154)'); | |
final ms = 150151152153154; | |
final millis = (ms / 1000).round(); | |
final micros = ms % 1000; | |
print('ms: $ms millis: $millis micros: $micros'); | |
final date = DateTime(1970,1,1,0,0,0,millis,micros); | |
print('date: $date micros since epoch: ${date.microsecondsSinceEpoch} micros: ${date.microsecond}'); | |
final d = DateTime(1970,1,1,0,0,0,0,ms); | |
print('date: $d micros since epoch: ${d.microsecondsSinceEpoch} micros: ${d.microsecond}'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
update: conversion isn't lossy on platform other than web and
DartPad
.