Connected Custom Watchfaces / Which Watch Face are Wearing Today?

Posts
18
Likes
27
QUESTION:

Need help programming.
Sample watch face:

You are reaching what are called edge cases. You need a function to actually do the math for you.

Something like this might work.I hhaven't tested it but the logic is there. I also apologize for the formating. I'm on my phone.


-- Function to get tomorrow's date function getTomorrow()
local currentDay = tonumber(os.date("%d"))

-- Get today's date as a number
local daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
local currentMonth = tonumber(os.date("%m"))
local currentYear = tonumber(os.date("%Y"))

-- Adjust for leap year
if (currentYear % 4 == 0 and (currentYear % 100 ~= 0 or currentYear % 400 == 0)) then
daysInMonth[2] = 29
end

-- Increment the day, adjust month and year if needed currentDay = currentDay + 1
if currentDay > daysInMonth[currentMonth] then
currentDay = 1
currentMonth = currentMonth + 1
if currentMonth > 12 then
currentMonth = 1
currentYear = currentYear + 1
end
end
return string.format("%02d/%02d/%04d", currentMonth, currentDay, currentYear)
end

-- Function to get yesterday's date function getYesterday()
local currentDay = tonumber(os.date("%d"))
local daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
local currentMonth = tonumber(os.date("%m"))
local currentYear = tonumber(os.date("%Y"))


-- Adjust for leap year
if (currentYear % 4 == 0 and (currentYear % 100 ~= 0 or currentYear % 400 == 0)) then daysInMonth[2] = 29 end

-- Decrement the day, adjust month and year if needed currentDay = currentDay - 1
if currentDay < 1 then
currentMonth = currentMonth - 1
if currentMonth < 1 then
currentMonth = 12
currentYear = currentYear - 1
end
currentDay = daysInMonth[currentMonth]
end

return string.format("%02d/%02d/%04d", currentMonth, currentDay, currentYear)
end

-- Display the dates text_layer_tomorrow = wm_tag("{dh23z}:{dmz}") .. " Tomorrow: " .. getTomorrow() text_layer_yesterday = wm_tag("{dh23z}:{dmz}") .. " Yesterday: " .. getYesterday()
 
Posts
442
Likes
853
S SirFM
You are reaching what are called edge cases. You need a function to actually do the math for you.

Something like this might work.I hhaven't tested it but the logic is there. I also apologize for the formating. I'm on my phone.


-- Function to get tomorrow's date function getTomorrow()
local currentDay = tonumber(os.date("%d"))

-- Get today's date as a number
local daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
local currentMonth = tonumber(os.date("%m"))
local currentYear = tonumber(os.date("%Y"))

-- Adjust for leap year
if (currentYear % 4 == 0 and (currentYear % 100 ~= 0 or currentYear % 400 == 0)) then
daysInMonth[2] = 29
end

-- Increment the day, adjust month and year if needed currentDay = currentDay + 1
if currentDay > daysInMonth[currentMonth] then
currentDay = 1
currentMonth = currentMonth + 1
if currentMonth > 12 then
currentMonth = 1
currentYear = currentYear + 1
end
end
return string.format("%02d/%02d/%04d", currentMonth, currentDay, currentYear)
end

-- Function to get yesterday's date function getYesterday()
local currentDay = tonumber(os.date("%d"))
local daysInMonth = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
local currentMonth = tonumber(os.date("%m"))
local currentYear = tonumber(os.date("%Y"))


-- Adjust for leap year
if (currentYear % 4 == 0 and (currentYear % 100 ~= 0 or currentYear % 400 == 0)) then daysInMonth[2] = 29 end

-- Decrement the day, adjust month and year if needed currentDay = currentDay - 1
if currentDay < 1 then
currentMonth = currentMonth - 1
if currentMonth < 1 then
currentMonth = 12
currentYear = currentYear - 1
end
currentDay = daysInMonth[currentMonth]
end

return string.format("%02d/%02d/%04d", currentMonth, currentDay, currentYear)
end

-- Display the dates text_layer_tomorrow = wm_tag("{dh23z}:{dmz}") .. " Tomorrow: " .. getTomorrow() text_layer_yesterday = wm_tag("{dh23z}:{dmz}") .. " Yesterday: " .. getYesterday()

WOW!

Thank you, I think I can work with that.
Super!
😀😀😀😀😀😀😀
 
Posts
155
Likes
460
PREGUNTA:

Necesita ayuda para programar.
Esfera de reloj de muestra:

[ADJUNTAR]1768702[/ADJUNTAR]

Lo que hice:
11 es la fecha.
Así que hice esto: {dd}
10 fue ayer: {dd}-1
12 es mañana: {dd)+1
Y así sucesivamente.
Lamentablemente no funciona a los 31 o 30 años.
¿Cómo programo eso?

Cualquier ayuda será apreciada. [/CITA]

Creo que la aplicación de WM tiene esa función específica en las series
 
Posts
2,412
Likes
9,027
How did you get this to attach to the watch head? It's a quick remove?


To use these straps you have to remove the original E3 links, by removing them you can use a normal pin and use any 22mm strap





With this you will do it without problem cutting the originals in half