Skip to content

Commit d603a2b

Browse files
Fixes
1 parent f9c21af commit d603a2b

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

templates/dart/lib/id.dart.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ID {
99
static String _hexTimestamp() {
1010
final now = DateTime.now();
1111
final sec = (now.millisecondsSinceEpoch / 1000).floor();
12-
final usec = (now.microsecondsSinceEpoch - sec) * 1000000;
12+
final usec = now.microsecondsSinceEpoch - (sec * 1000000);
1313
return sec.toRadixString(16) +
1414
usec.toRadixString(16).padLeft(5, '0');
1515
}

templates/dotnet/src/Appwrite/ID.cs.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace {{ spec.title | caseUcfirst }}
1111
var now = DateTime.UtcNow;
1212
var epoch = (now - new DateTime(1970, 1, 1));
1313
var sec = (long)epoch.TotalSeconds;
14-
var usec = (long)(epoch.TotalMilliseconds * 1000);
14+
var usec = (long)((epoch.TotalMilliseconds * 1000) % 1000);
1515

1616
// Convert to hexadecimal
1717
var hexTimestamp = sec.ToString("x") + usec.ToString("x").PadLeft(5, '0');

templates/kotlin/src/main/kotlin/io/appwrite/ID.kt.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ class ID {
1111
private fun hexTimestamp(): String {
1212
val now = Instant.now()
1313
val sec = now.epochSecond
14-
val usec = System.nanoTime() / 1000
14+
val usec = (System.nanoTime() / 1000) % 1000
1515

16-
val hexTimestamp = "%08x%05x".format(sec, millis)
16+
val hexTimestamp = "%08x%05x".format(sec, usec)
1717

1818
return hexTimestamp
1919
}

0 commit comments

Comments
 (0)