Loading src/main/kotlin/at/bitfire/dav4jvm/HttpUtils.kt +6 −6 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ import java.util.* object HttpUtils { const val httpDateFormatStr = "EEE, dd MMM yyyy HH:mm:ss 'GMT'" val httpDateFormat = SimpleDateFormat(httpDateFormatStr, Locale.ROOT) private const val httpDateFormatStr = "EEE, dd MMM yyyy HH:mm:ss zzz" private val httpDateFormat = SimpleDateFormat(httpDateFormatStr, Locale.ROOT) /** * Gets the resource name (the last segment of the path) from an URL. Loading Loading @@ -58,8 +58,8 @@ object HttpUtils { */ fun parseDate(dateStr: String) = try { DateUtils.parseDate(dateStr, Locale.US, httpDateFormatStr, "EEE, dd MMM yyyy HH:mm:ss zzz", // RFC 822, updated by RFC 1123 with any TZ httpDateFormatStr, // RFC 822, updated by RFC 1123 with any TZ "EEE, dd MMM yyyy HH:mm:ss zzz", "EEEE, dd-MMM-yy HH:mm:ss zzz", // RFC 850, obsoleted by RFC 1036 with any TZ. "EEE MMM d HH:mm:ss yyyy", // ANSI C's asctime() format // Alternative formats. Loading src/test/kotlin/at/bitfire/dav4jvm/HttpUtilsTest.kt +6 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ import org.junit.Test class HttpUtilsTest { @Test fun testFilename() { fun fileName() { assertEquals("", HttpUtils.fileName("https://example.com".toHttpUrl())) assertEquals("", HttpUtils.fileName("https://example.com/".toHttpUrl())) assertEquals("file1", HttpUtils.fileName("https://example.com/file1".toHttpUrl())) Loading @@ -22,4 +22,9 @@ class HttpUtilsTest { assertEquals("dir2", HttpUtils.fileName("https://example.com/dir1/dir2/".toHttpUrl())) } @Test fun parseDate() { assertEquals(1683825995000, HttpUtils.parseDate("Thu, 11 May 2023 17:26:35 GMT")?.time) } } Loading
src/main/kotlin/at/bitfire/dav4jvm/HttpUtils.kt +6 −6 Original line number Diff line number Diff line Loading @@ -16,8 +16,8 @@ import java.util.* object HttpUtils { const val httpDateFormatStr = "EEE, dd MMM yyyy HH:mm:ss 'GMT'" val httpDateFormat = SimpleDateFormat(httpDateFormatStr, Locale.ROOT) private const val httpDateFormatStr = "EEE, dd MMM yyyy HH:mm:ss zzz" private val httpDateFormat = SimpleDateFormat(httpDateFormatStr, Locale.ROOT) /** * Gets the resource name (the last segment of the path) from an URL. Loading Loading @@ -58,8 +58,8 @@ object HttpUtils { */ fun parseDate(dateStr: String) = try { DateUtils.parseDate(dateStr, Locale.US, httpDateFormatStr, "EEE, dd MMM yyyy HH:mm:ss zzz", // RFC 822, updated by RFC 1123 with any TZ httpDateFormatStr, // RFC 822, updated by RFC 1123 with any TZ "EEE, dd MMM yyyy HH:mm:ss zzz", "EEEE, dd-MMM-yy HH:mm:ss zzz", // RFC 850, obsoleted by RFC 1036 with any TZ. "EEE MMM d HH:mm:ss yyyy", // ANSI C's asctime() format // Alternative formats. Loading
src/test/kotlin/at/bitfire/dav4jvm/HttpUtilsTest.kt +6 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ import org.junit.Test class HttpUtilsTest { @Test fun testFilename() { fun fileName() { assertEquals("", HttpUtils.fileName("https://example.com".toHttpUrl())) assertEquals("", HttpUtils.fileName("https://example.com/".toHttpUrl())) assertEquals("file1", HttpUtils.fileName("https://example.com/file1".toHttpUrl())) Loading @@ -22,4 +22,9 @@ class HttpUtilsTest { assertEquals("dir2", HttpUtils.fileName("https://example.com/dir1/dir2/".toHttpUrl())) } @Test fun parseDate() { assertEquals(1683825995000, HttpUtils.parseDate("Thu, 11 May 2023 17:26:35 GMT")?.time) } }