From 4f0f2fe5e53defc65039bccead72775da8d13638 Mon Sep 17 00:00:00 2001
From: Delaigue Olivier <olivier.delaigue@irstea.fr>
Date: Wed, 14 Jul 2021 07:39:37 +0200
Subject: [PATCH] feat(Utils): add a function to try to set local time in
 English Refs #122

---
 R/Utils.R | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/R/Utils.R b/R/Utils.R
index 0b9e988d..82c66da0 100644
--- a/R/Utils.R
+++ b/R/Utils.R
@@ -232,3 +232,27 @@
     NextMethod()
   }
 }
+
+
+
+## =================================================================================
+## function to try to set local time in English
+## =================================================================================
+
+.TrySetLcTimeEN <- function() {
+  locale <- list("English_United Kingdom",
+                 "en_US",
+                 "en_US.UTF-8",
+                 "en_US.utf8",
+                 "en")
+  dateTest <- as.POSIXct("2000-02-15", tz = "UTC", format = "%Y-%m-%d")
+  monthTestTarget <- "February"
+  monthTest <- function() {
+    format(dateTest, format = "%B")
+  }
+  lapply(locale, function(x) {
+    if (monthTest() != monthTestTarget) {
+      Sys.setlocale(category = "LC_TIME", locale = x)
+    }
+  })
+}
-- 
GitLab