Skip to content

ShowDatePicker Misses dates when UseLocalTime = true #256

Open
@peterwilson136

Description

@peterwilson136

Using the code below, if you click on June 2021 -> Jan ->1 (and make sure you click on the 1), and then you go back to January 2021 -> Jun, it puts the date to 31 May, 2021. You can repeat this for May, June, July, August, September, October, and you will see that it only works up till April and after November.

#include <GL/glew.h>

#ifndef GLFW_INCLUDE_NONE
#define GLFW_INCLUDE_NONE // GLFW including OpenGL headers causes ambiguity or multiple definition errors.
#endif // GLFW_INCLUDE_NONE

#include <GLFW/glfw3.h>

#include "ImGui/imgui.h"
#include "ImGui/implot.h"
#include "ImGui/implot_internal.h"
#include "ImGui/imgui_impl_glfw.h"
#include "ImGui/imgui_impl_opengl3.h"



int main(int argc, char* argv[])
{
    glfwInit();
    GLFWwindow* window = glfwCreateWindow(1280, 720, "Program", NULL, NULL);
    glfwMakeContextCurrent(window);
    glfwSwapInterval(0); //  vsync

    glewInit();

    IMGUI_CHECKVERSION();
    ImGui::CreateContext();
    ImPlot::CreateContext();

    ImGui::StyleColorsDark();
    ImPlotStyle& ImPlot_Style = ImPlot::GetStyle();
    ImPlot_Style.UseLocalTime = true;

    ImGui_ImplGlfw_InitForOpenGL(window, true);
    ImGui_ImplOpenGL3_Init("#version 460");

    static ImPlotTime from = 1623938400 - 86400;
    static int fromLevel = 0;

    while (!glfwWindowShouldClose(window))
    {
        glfwPollEvents();

        ImGui_ImplOpenGL3_NewFrame();
        ImGui_ImplGlfw_NewFrame();
        ImGui::NewFrame();


        ImGui::Text("%.3f", ImGui::GetIO().Framerate);
        ImPlot::ShowDatePicker("##ComparisonBefore", &fromLevel, &from, nullptr, &from);
    

        ImGui::Render();
        glClearColor(0.45f, 0.55f, 0.60f, 1.00f);
        glClear(GL_COLOR_BUFFER_BIT);
        ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
        glfwSwapBuffers(window);
    }

    ImGui_ImplOpenGL3_Shutdown();
    ImGui_ImplGlfw_Shutdown();
    ImPlot::DestroyContext();
    ImGui::DestroyContext();

    glfwDestroyWindow(window);
    glfwTerminate();

    return 0;
}

Edit:
I think it has to do with ImPlot_Style.UseLocalTime = true;, because removing this solves the issue, however in my main program it messes with the time in the plot axis.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions