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

Fix timezone formatting for Android 6 and below in Local Server mode #66

Merged
merged 1 commit into from
May 8, 2024
Merged
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import me.capcom.smsgateway.modules.messages.data.SendRequest
import me.capcom.smsgateway.modules.notifications.NotificationsService
import org.koin.android.ext.android.inject
import java.util.Date
import java.util.TimeZone
import kotlin.concurrent.thread

class WebService : Service() {
Expand Down Expand Up @@ -76,10 +77,24 @@ class WebService : Service() {
if (me.capcom.smsgateway.BuildConfig.DEBUG) {
setPrettyPrinting()
}
// ISO_8601
this.setDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
this.setDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.SSSXXX"
)
} else {
//get device timezone
val timeZone = TimeZone.getDefault()
this.setDateFormat(
"yyyy-MM-dd'T'HH:mm:ss.SSS" + when (timeZone.rawOffset) {
0 -> "Z"
else -> "+" + (timeZone.rawOffset / 3600000).toString().padStart(
2,
'0'
) + ":" + ((timeZone.rawOffset % 3600000) / 60000).toString()
.padStart(2, '0')
}
)
}
}
}
install(StatusPages) {
Expand Down
Loading