## Get the time
# AM / PM (initial code)
scoreboard players set @s vb.dummy5 0
# Day of the year (initial code)
execute store result score @s vb.dummy2 run time query day
# Hour
execute store result score @s vb.dummy3 run time query daytime
scoreboard players set @s vb.dummy1 1000
scoreboard players operation @s vb.dummy3 /= @s vb.dummy1
scoreboard players add @s vb.dummy3 6
# Past noon
execute if score @s vb.dummy3 matches 12..23 run scoreboard players set @s vb.dummy5 1
execute if score @s vb.dummy3 matches 13..23 run scoreboard players remove @s vb.dummy3 12
# Past midnight
execute if score @s vb.dummy3 matches 24.. run scoreboard players add @s vb.dummy2 1
execute if score @s vb.dummy3 matches 24.. run scoreboard players set @s vb.dummy5 0
execute if score @s vb.dummy3 matches 24 run scoreboard players remove @s vb.dummy3 12
execute if score @s vb.dummy3 matches 25.. run scoreboard players remove @s vb.dummy3 24
# Day of the year (more code)
scoreboard players set @s vb.dummy1 365
scoreboard players operation @s vb.dummy2 %= @s vb.dummy1
scoreboard players add @s vb.dummy2 1
# Day of month (will be calculated more later)
scoreboard players operation @s vb.dummy4 = @s vb.dummy2

## Other dimensions
execute unless dimension minecraft:overworld run scoreboard players set @s vb.dummy2 99999

## Display in action bar
# January
execute if score @s vb.dummy2 matches 1..31 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'January '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 1..31 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'January '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# February
execute if score @s vb.dummy2 matches 32..59 run scoreboard players remove @s vb.dummy4 31
execute if score @s vb.dummy2 matches 32..59 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'February '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 32..59 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'February '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# March
execute if score @s vb.dummy2 matches 60..90 run scoreboard players remove @s vb.dummy4 59
execute if score @s vb.dummy2 matches 60..90 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'March '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 60..90 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'March '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# April
execute if score @s vb.dummy2 matches 91..120 run scoreboard players remove @s vb.dummy4 90
execute if score @s vb.dummy2 matches 91..120 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'April '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 91..120 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'April '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# May
execute if score @s vb.dummy2 matches 121..151 run scoreboard players remove @s vb.dummy4 120
execute if score @s vb.dummy2 matches 121..151 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'May '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 121..151 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'May '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# June
execute if score @s vb.dummy2 matches 152..181 run scoreboard players remove @s vb.dummy4 151
execute if score @s vb.dummy2 matches 152..181 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'June '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 152..181 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'June '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# July
execute if score @s vb.dummy2 matches 182..212 run scoreboard players remove @s vb.dummy4 181
execute if score @s vb.dummy2 matches 182..212 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'July '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 182..212 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'July '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# August
execute if score @s vb.dummy2 matches 213..243 run scoreboard players remove @s vb.dummy4 212
execute if score @s vb.dummy2 matches 213..243 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'August '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 213..243 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'August '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# September
execute if score @s vb.dummy2 matches 244..273 run scoreboard players remove @s vb.dummy4 243
execute if score @s vb.dummy2 matches 244..273 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'September '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 244..273 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'September '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# October
execute if score @s vb.dummy2 matches 274..304 run scoreboard players remove @s vb.dummy4 273
execute if score @s vb.dummy2 matches 274..304 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'October '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 274..304 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'October '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# November
execute if score @s vb.dummy2 matches 305..334 run scoreboard players remove @s vb.dummy4 304
execute if score @s vb.dummy2 matches 305..334 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'November '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 305..334 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'November '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# December
execute if score @s vb.dummy2 matches 334..365 run scoreboard players remove @s vb.dummy4 334
execute if score @s vb.dummy2 matches 334..365 if score @s vb.dummy5 matches 0 run title @s actionbar [{text:'December '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'am',color:yellow}]
execute if score @s vb.dummy2 matches 334..365 if score @s vb.dummy5 matches 1 run title @s actionbar [{text:'December '},{score:{name:'@s',objective:vb.dummy4}},{text:' '},{score:{name:'@s',objective:vb.dummy3},color:yellow},{text:'pm',color:yellow}]
# Other dimensions
execute if score @s vb.dummy2 matches 99999 run title @s actionbar [{text:'December 00 ',obfuscated:true},{text:'00mm',color:yellow,obfuscated:true}]
