From f8e7cf3f3b8cf65054868d8e3ba5533da9c9a1e9 Mon Sep 17 00:00:00 2001 From: Igor Timofeev Date: Sat, 19 May 2018 22:14:43 +0300 Subject: [PATCH] ))))))) --- Localizations/OS/English.lang | 16 ++-------------- Localizations/OS/French.lang | 16 ++-------------- Localizations/OS/Russian.lang | 16 ++-------------- OS.lua | 25 +++++++++++++++++-------- lib/MineOSCore.lua | 1 + 5 files changed, 24 insertions(+), 50 deletions(-) diff --git a/Localizations/OS/English.lang b/Localizations/OS/English.lang index 9db70629..ac12a6c3 100755 --- a/Localizations/OS/English.lang +++ b/Localizations/OS/English.lang @@ -154,21 +154,9 @@ inCurrentDirectory = "In current directory", settings = "Preferences", - months = { - Jan = "Jan", - Feb = "Feb", - Mar = "Mar", - Apr = "Apr", - May = "May", - Jun = "Jun", - Jul = "Jul", - Aug = "Aug", - Sep = "Sep", - Oct = "Oct", - Nov = "Nov", - Dec = "Dec", - }, + dateAndTime = "Date and time", timezone = "Timezone", + dateFormat = "Date format", errorWhileRunningProgram = "Error while running ", sendedFeedback = "Feedback was sent", diff --git a/Localizations/OS/French.lang b/Localizations/OS/French.lang index d46faa52..0b15ca57 100644 --- a/Localizations/OS/French.lang +++ b/Localizations/OS/French.lang @@ -154,21 +154,9 @@ inCurrentDirectory = "Dans le répertoire actuel", settings = "Préférences", - months = { - Jan = "Jan", - Feb = "Fev", - Mar = "Mar", - Apr = "Avr", - May = "Mai", - Jun = "Jui", - Jul = "Juil", - Aug = "Aou", - Sep = "Sep", - Oct = "Oct", - Nov = "Nov", - Dec = "Dec", - }, + dateAndTime = "Date et heure", timezone = "Fuseau horaire", + dateFormat = "Format de date", errorWhileRunningProgram = "Erreur lors de l'exécution ", sendedFeedback = "Votre commantaire a bien été envoyé", diff --git a/Localizations/OS/Russian.lang b/Localizations/OS/Russian.lang index 09bd3754..91c0333b 100755 --- a/Localizations/OS/Russian.lang +++ b/Localizations/OS/Russian.lang @@ -154,21 +154,9 @@ inCurrentDirectory = "В текущей директории", settings = "Настройки", - months = { - Jan = "Января", - Feb = "Февраля", - Mar = "Марта", - Apr = "Апреля", - May = "Мая", - Jun = "Июня", - Jul = "Июля", - Aug = "Августа", - Sep = "Сентября", - Oct = "Октября", - Nov = "Ноября", - Dec = "Декабря", - }, + dateAndTime = "Дата и время", timezone = "Часовой пояс", + dateFormat = "Формат даты", errorWhileRunningProgram = "Ошибка при выполнении ", sendedFeedback = "Отчет отправлен", diff --git a/OS.lua b/OS.lua index 9742f29f..9582b913 100755 --- a/OS.lua +++ b/OS.lua @@ -942,20 +942,31 @@ local function createOSWidgets() showHiddenFilesSwitch.onStateChanged, showApplicationIconsSwitch.onStateChanged = showExtensionSwitch.onStateChanged, showExtensionSwitch.onStateChanged end - menu:addItem(MineOSCore.localization.timezone).onTouch = function() + menu:addItem(MineOSCore.localization.dateAndTime).onTouch = function() local container = MineOSInterface.addBackgroundContainer(MineOSInterface.mainContainer, MineOSCore.localization.timezone) local comboBox = container.layout:addChild(GUI.comboBox(1, 1, 36, 3, 0xE1E1E1, 0x2D2D2D, 0x4B4B4B, 0x969696)) comboBox.dropDownMenu.itemHeight = 1 + + local label = container.layout:addChild(GUI.label(1, 1, container.width, 1, 0xE1E1E1, MineOSCore.localization.dateFormat):setAlignment(GUI.ALIGNMENT_HORIZONTAL_CENTER, GUI.ALIGNMENT_VERTICAL_TOP)) + + local input = container.layout:addChild(GUI.input(1, 1, 36, 3, 0xE1E1E1, 0x696969, 0x878787, 0xE1E1E1, 0x2D2D2D, MineOSCore.properties.dateFormat or "")) + input.onInputFinished = function() + MineOSCore.properties.dateFormat = input.text + MineOSCore.OSUpdateDate() + + MineOSInterface.mainContainer:drawOnScreen() + MineOSCore.saveProperties() + end for i = -12, 12 do comboBox:addItem("GMT" .. (i >= 0 and "+" or "") .. i).onTouch = function() MineOSCore.properties.timezone = i - MineOSCore.saveProperties() - MineOSCore.OSUpdateTimezone(i) MineOSCore.OSUpdateDate() + MineOSInterface.mainContainer:drawOnScreen() + MineOSCore.saveProperties() end end @@ -1026,12 +1037,10 @@ local function createOSWidgets() fs.remove(name) end - local firstPart, month, secondPart = os.date( - "%d %b %Y %T", + dateWidgetText = os.date( + MineOSCore.properties.dateFormat, realTimestamp + computerDateUptime - computerUptimeOnBoot + timezoneCorrection - ):match("(%d+%s)(%a+)(.+)") - - dateWidgetText = firstPart .. (MineOSCore.localization.months[month] or "monthNotAvailable:" .. month) .. secondPart + ) dateWidget.width = unicode.len(dateWidgetText) batteryWidgetPercent = computer.energy() / computer.maxEnergy() diff --git a/lib/MineOSCore.lua b/lib/MineOSCore.lua index 3be7a52b..5f0fe33e 100755 --- a/lib/MineOSCore.lua +++ b/lib/MineOSCore.lua @@ -85,6 +85,7 @@ function MineOSCore.loadPropeties() end local defaultValues = { + dateFormat = "%d %b% %Y %H:%M:%S", packageUnloading = true, transparencyEnabled = true, showApplicationIcons = true,