Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 54
ADFA-2248 | Implement created/modified date logic across project components#689
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
518c0dad6b7c66d44f565b5027a5ee2e11996bd52b0b0d6c74284ae5c8f92005723816File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -11,5 +11,6 @@ data class RecentProject( | ||
| @ColumnInfo(name = "name") val name: String, | ||
| @ColumnInfo(name = "create_at") val createdAt: String, | ||
| @ColumnInfo(name = "location") val location: String, | ||
| @ColumnInfo(name = "last_modified") val lastModified: String = "0" | ||
jatezzz marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.itsaky.androidide.utils | ||
| import java.text.SimpleDateFormat | ||
| import java.util.Date | ||
| import java.util.Locale | ||
| fun formatDate(dateString: String): String { | ||
| return runCatching { | ||
| val outputFormat = SimpleDateFormat("dd MMM yyyy, HH:mm", Locale.US) | ||
| if (dateString.all { it.isDigit() }) { | ||
| val millis = dateString.toLong() | ||
| val date = Date(millis) | ||
| return@runCatching outputFormat.format(date) | ||
| } | ||
| val inputFormat = SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.ENGLISH) | ||
| val date = inputFormat.parse(dateString) ?: return dateString.take(5) | ||
| outputFormat.format(date) | ||
jatezzz marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. jatezzz marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| }.getOrElse { | ||
| dateString.take(5) | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package com.itsaky.androidide.utils | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.withContext | ||
| import java.nio.file.Files | ||
| import java.nio.file.Paths | ||
| import java.nio.file.attribute.BasicFileAttributes | ||
| fun getAttrs(location: String): BasicFileAttributes? { | ||
| return runCatching { | ||
| Files.readAttributes(Paths.get(location), BasicFileAttributes::class.java) | ||
| }.getOrNull() | ||
| } | ||
| suspend fun getLastModifiedTime(location: String): Long = withContext(Dispatchers.IO) { | ||
| val projectAttrs = getAttrs(location) ?: return@withContext System.currentTimeMillis() | ||
| return@withContext projectAttrs.lastModifiedTime().toMillis() | ||
| } | ||
| suspend fun getCreatedTime(location: String): Long = withContext(Dispatchers.IO) { | ||
| val projectAttrs = getAttrs(location) ?: return@withContext System.currentTimeMillis() | ||
| return@withContext projectAttrs.creationTime().toMillis() | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.