mirror of
https://gitlab.com/4w/mtimer.git
synced 2024-11-24 16:23:44 +01:00
implement meridiem indicator
implements https://gitlab.com/4w/mtimer/-/issues/20
This commit is contained in:
parent
f90cba8852
commit
91c967cf4f
@ -99,7 +99,7 @@ Stop stop custom timer=Individuellen Timer anhalten
|
||||
Restart the custom timer=Individuellen Timer neu starten
|
||||
|
||||
|
||||
# Custonm timer status messages
|
||||
# Default custom timer status messages
|
||||
The custom timer is already running=Der individuelle Timer läuft bereits
|
||||
The custom timer is not running=Der individuelle Timer läuft nicht
|
||||
The custom timer was started=Der individuelle Timer wurde gestartet
|
||||
@ -188,3 +188,10 @@ September=September
|
||||
Oktober=Oktober
|
||||
November=November
|
||||
December=Dezember
|
||||
|
||||
|
||||
# Related to the meridiem indicator
|
||||
Meridiem Indicator=Tageshälftenhinweis
|
||||
am=vorm.
|
||||
pm=nachm.
|
||||
(ERROR)=(FEHLER)
|
||||
|
@ -59,9 +59,10 @@ mtimer.dialog.ingame_time_format = function (player_name)
|
||||
line(2, S('Hours (24h)'), '{24h}', time_data.hours_24),
|
||||
line(3, S('Hours (12h)'), '{12h}', time_data.hours_12),
|
||||
line(4, S('Minutes'), '{min}', time_data.minutes),
|
||||
line(5, S('Ingame Timestamp'), '{its}', time_data.ingame_timestamp),
|
||||
line(6, '-'),
|
||||
line(7, S('Current Result'), esc(time_data.formatted), ''),
|
||||
line(5, S('Meridiem Indicator'),'{mi}', time_data.indicator),
|
||||
line(6, S('Ingame Timestamp'), '{its}', time_data.ingame_timestamp),
|
||||
line(7, '-'),
|
||||
line(8, S('Current Result'), esc(time_data.formatted), ''),
|
||||
'container_end[]'
|
||||
}
|
||||
})
|
||||
|
@ -22,7 +22,7 @@ mtimer.dialog.real_time_universal = function (player_name, config)
|
||||
mtimer.show_formspec(config.formspec_name, {
|
||||
title = config.title,
|
||||
show_to = player_name,
|
||||
height = 8.75,
|
||||
height = 9,
|
||||
formspec = {
|
||||
'field_close_on_enter[format;false]',
|
||||
'field[0,0;+contentWidth,0.5;format;;'..esc(time_data.format)..']',
|
||||
@ -33,19 +33,20 @@ mtimer.dialog.real_time_universal = function (player_name, config)
|
||||
line(3, S('Hours (12h)'), '{12h}', vars.hours_12),
|
||||
line(4, S('Minutes'), '{min}', vars.minutes),
|
||||
line(5, S('Seconds'), '{sec}', vars.seconds),
|
||||
line(6, '-'),
|
||||
line(7, S('Day Name'), '{dname}', vars.dayname),
|
||||
line(8, S('Month Name'), '{mname}', vars.monthname),
|
||||
line(9, '-'),
|
||||
line(10, S('Year'), '{year}', vars.year),
|
||||
line(11, S('Month'), '{month}', vars.month),
|
||||
line(12, S('Day'), '{day}', vars.day),
|
||||
line(13, '-'),
|
||||
line(14, S('ISO 8601 Date'), '{isodate}', vars.iso8601_date),
|
||||
line(15, S('ISO 8601 Time'), '{isotime}', vars.iso8601_time),
|
||||
line(16, S('Timestamp'), '{timestamp}', vars.timestamp),
|
||||
line(17, '-'),
|
||||
line(18, S('Current Result'), esc(time_data.formatted), ''),
|
||||
line(6, S('Meridiem Indicator'), '{mi}', vars.indicator),
|
||||
line(7, '-'),
|
||||
line(8, S('Day Name'), '{dname}', vars.dayname),
|
||||
line(9, S('Month Name'), '{mname}', vars.monthname),
|
||||
line(10, '-'),
|
||||
line(11, S('Year'), '{year}', vars.year),
|
||||
line(12, S('Month'), '{month}', vars.month),
|
||||
line(13, S('Day'), '{day}', vars.day),
|
||||
line(14, '-'),
|
||||
line(15, S('ISO 8601 Date'), '{isodate}', vars.iso8601_date),
|
||||
line(16, S('ISO 8601 Time'), '{isotime}', vars.iso8601_time),
|
||||
line(17, S('Timestamp'), '{timestamp}', vars.timestamp),
|
||||
line(18, '-'),
|
||||
line(19, S('Current Result'), esc(time_data.formatted), ''),
|
||||
'container_end[]'
|
||||
}
|
||||
})
|
||||
|
@ -3,6 +3,22 @@ local S = m.translator
|
||||
local ds = minetest.deserialize
|
||||
|
||||
|
||||
-- Manually calculate am/pm
|
||||
--
|
||||
-- Because %p returns am/pm or nothing depending on current locale it is not
|
||||
-- reliable to use it. This function takes a 24h hours value and returns the
|
||||
-- correct meridiem indicator.
|
||||
--
|
||||
-- @param hour The hour to get the indicator for in 24h format
|
||||
-- @return string The meridiem indicator for that hour
|
||||
local get_mi = function (hour)
|
||||
local s_hour = tonumber(hour)
|
||||
if s_hour >= 0 and s_hour <= 11 then return S('am') end -- midnight->noon
|
||||
if s_hour >= 12 and s_hour <= 23 then return S('pm') end -- noon->midnight
|
||||
return S('(ERROR)')
|
||||
end
|
||||
|
||||
|
||||
-- Get translated date names
|
||||
--
|
||||
-- This helper function takes a table containing a numerical month and a
|
||||
@ -111,6 +127,7 @@ local get_real_time_universal = function (player_name, time_type)
|
||||
hours_12 = os.date(force_utc..'%I', local_timestamp),
|
||||
minutes = os.date(force_utc..'%M', local_timestamp),
|
||||
seconds = os.date(force_utc..'%S', local_timestamp),
|
||||
indicator = get_mi(os.date(force_utc..'%H', local_timestamp)),
|
||||
dayname = date_names.day,
|
||||
monthname = date_names.month,
|
||||
year = os.date(force_utc..'%Y', local_timestamp),
|
||||
@ -128,6 +145,7 @@ local get_real_time_universal = function (player_name, time_type)
|
||||
['{12h}'] = values.variables.hours_12,
|
||||
['{min}'] = values.variables.minutes,
|
||||
['{sec}'] = values.variables.seconds,
|
||||
['{mi}'] = values.variables.indicator,
|
||||
['{dname}'] = values.variables.dayname,
|
||||
['{mname}'] = values.variables.monthname,
|
||||
['{year}'] = values.variables.year,
|
||||
@ -182,6 +200,7 @@ local get_ingame_time = function (player_name)
|
||||
hours_24 = os.date('!%H', ingame_timestamp),
|
||||
hours_12 = os.date('!%I', ingame_timestamp),
|
||||
minutes = os.date('!%M', ingame_timestamp),
|
||||
indicator = get_mi(os.date(os.date('!%H', ingame_timestamp))),
|
||||
ingame_timestamp = ingame_timestamp,
|
||||
format = format
|
||||
}
|
||||
@ -190,6 +209,7 @@ local get_ingame_time = function (player_name)
|
||||
['{24h}'] = values.hours_24,
|
||||
['{12h}'] = values.hours_12,
|
||||
['{min}'] = values.minutes,
|
||||
['{mi}'] = values.indicator,
|
||||
['{its}'] = values.ingame_timestamp
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user