From b6626c4132f941b6e202484359c15d5928bd232a Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 21 Jul 2021 16:29:56 -0400 Subject: [PATCH 1/4] add tomorrow --- src/schedule.jl | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/src/schedule.jl b/src/schedule.jl index 7a8b089..c69d721 100644 --- a/src/schedule.jl +++ b/src/schedule.jl @@ -258,7 +258,7 @@ function today(; return today(Val(output); now, track, terminal_links) end -function today(::Val{:terminal}; now, track, terminal_links) +function today(::Val{:terminal}; now, track, terminal_links, highlighting=true) tracks, tables, highlighters = _get_today_tables(; now, track, terminal_links) isnothing(tables) && return nothing @@ -267,6 +267,9 @@ function today(::Val{:terminal}; now, track, terminal_links) border_crayon = crayon"dark_gray" h_times = Highlighter((data, i, j) -> j == 1, crayon"white bold") + println() + println(TimeZones.Date(now)) + for j in eachindex(tracks) track = tracks[j] data = tables[j] @@ -286,11 +289,13 @@ function today(::Val{:terminal}; now, track, terminal_links) end println() - printstyled("Currently running talks are highlighted in ") - printstyled("yellow"; color=:yellow) - printstyled(".") - println() - println() + if highlighting + printstyled("Currently running talks are highlighted in ") + printstyled("yellow"; color=:yellow) + printstyled(".") + println() + println() + end print(abbrev(Talk), " = Talk, ") print(abbrev(LightningTalk), " = Lightning Talk, ") print(abbrev(SponsorTalk), " = Sponsor Talk, ") @@ -305,7 +310,7 @@ function today(::Val{:terminal}; now, track, terminal_links) return nothing end -function today(::Val{:text}; now, track, terminal_links) +function today(::Val{:text}; now, track, terminal_links, highlighting=true) tracks, tables, highlighters = _get_today_tables(; now, track, terminal_links) isnothing(tables) && return nothing @@ -334,9 +339,16 @@ function today(::Val{:text}; now, track, terminal_links) push!(strings, str) end - legend = """ - Currently running talks are highlighted in yellow (or not cause WIP). + legend = if highlighting + """ + Currently running talks are highlighted in yellow (or not cause WIP). + """ + else + "" + end + + legend *= """ $(JuliaCon.abbrev(JuliaCon.Talk)) = Talk, $(JuliaCon.abbrev(JuliaCon.LightningTalk)) = Lightning Talk, $(JuliaCon.abbrev(JuliaCon.SponsorTalk)) = Sponsor Talk, $(JuliaCon.abbrev(JuliaCon.Keynote)) = Keynote, $(JuliaCon.abbrev(JuliaCon.Workshop)) = Workshop, $(JuliaCon.abbrev(JuliaCon.Minisymposium)) = Minisymposium, $(JuliaCon.abbrev(JuliaCon.BoF)) = Birds of Feather, $(JuliaCon.abbrev(JuliaCon.Experience)) = Experience, $(JuliaCon.abbrev(JuliaCon.VirtualPoster)) = Virtual Poster @@ -346,3 +358,12 @@ function today(::Val{:text}; now, track, terminal_links) push!(strings, legend) return strings end + +function tomorrow(; + now=default_now(), + track=nothing, + terminal_links=TERMINAL_LINKS, + output=:terminal, # can take the :text value to output a Vector{String} +) + return today(Val(output); now = now + Dates.Day(1), track, terminal_links, highlighting = false) +end From 905c1f6042c0e006eb32d2144d7415f8b92253ba Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 21 Jul 2021 18:27:15 -0400 Subject: [PATCH 2/4] add test --- test/runtests.jl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index faf6151..b0b0275 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -60,6 +60,8 @@ using TimeZones @test isnothing(JuliaCon.today()) @test isnothing(JuliaCon.today(track="BoF")) @test isnothing(JuliaCon.today(terminal_links=true)) + @test isnothing(JuliaCon.tomorrow()) + @test isnothing(JuliaCon.tomorrow()) # output to text (Vector{Sting}) println("\n") From 60192935a59774a07c625568d9cb27065eb371a9 Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 22 Jul 2021 13:30:39 -0400 Subject: [PATCH 3/4] review fixes --- src/schedule.jl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/schedule.jl b/src/schedule.jl index c69d721..f035a59 100644 --- a/src/schedule.jl +++ b/src/schedule.jl @@ -207,7 +207,7 @@ function _get_current_talk_highlighter(talks; now=default_now()) end function _get_today_tables(; - now=default_now(), track=nothing, terminal_links=TERMINAL_LINKS + now=default_now(), track=nothing, terminal_links=TERMINAL_LINKS, highlighting=true ) track_schedules = get_today(; now=now) isnothing(track_schedules) && return (nothing, nothing, nothing) @@ -230,7 +230,11 @@ function _get_today_tables(; end push!(tables, data) - h_current = _get_current_talk_highlighter(talks; now=now) + h_current = if highlighting + _get_current_talk_highlighter(talks; now=now) + else + Highlighter((data, m, n) -> false, crayon"yellow") + end push!(highlighters, h_current) end @@ -259,7 +263,7 @@ function today(; end function today(::Val{:terminal}; now, track, terminal_links, highlighting=true) - tracks, tables, highlighters = _get_today_tables(; now, track, terminal_links) + tracks, tables, highlighters = _get_today_tables(; now, track, terminal_links, highlighting) isnothing(tables) && return nothing header = (["Time", "Title", "Type", "Speaker"],) @@ -268,7 +272,7 @@ function today(::Val{:terminal}; now, track, terminal_links, highlighting=true) h_times = Highlighter((data, i, j) -> j == 1, crayon"white bold") println() - println(TimeZones.Date(now)) + println(Dates.format(TimeZones.Date(now), "E d U Y")) for j in eachindex(tracks) track = tracks[j] @@ -311,7 +315,7 @@ function today(::Val{:terminal}; now, track, terminal_links, highlighting=true) end function today(::Val{:text}; now, track, terminal_links, highlighting=true) - tracks, tables, highlighters = _get_today_tables(; now, track, terminal_links) + tracks, tables, highlighters = _get_today_tables(; now, track, terminal_links, highlighting) isnothing(tables) && return nothing header = (["Time", "Title", "Type", "Speaker"],) @@ -320,6 +324,7 @@ function today(::Val{:text}; now, track, terminal_links, highlighting=true) h_times = Highlighter((data, i, j) -> j == 1, crayon"white bold") strings = Vector{String}() + push!(strings, string(Dates.format(TimeZones.Date(now), "E d U Y"))) for j in eachindex(tracks) track = tracks[j] data = tables[j] From 791de1c5e9ea22f42f5cd572688725e45118d5fd Mon Sep 17 00:00:00 2001 From: Ian Date: Thu, 22 Jul 2021 13:58:50 -0400 Subject: [PATCH 4/4] rm extra test --- test/runtests.jl | 1 - 1 file changed, 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index b0b0275..78442b5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -61,7 +61,6 @@ using TimeZones @test isnothing(JuliaCon.today(track="BoF")) @test isnothing(JuliaCon.today(terminal_links=true)) @test isnothing(JuliaCon.tomorrow()) - @test isnothing(JuliaCon.tomorrow()) # output to text (Vector{Sting}) println("\n")