j4321 / tkcalendar

Calendar widget for Tkinter
https://pypi.python.org/pypi/tkcalendar
GNU General Public License v3.0
97 stars 33 forks source link

DateEntry get_date() doesn't return correct selected date #74

Open TomiwaJoseph opened 3 years ago

TomiwaJoseph commented 3 years ago

If year 1993-02-28 was selected in the DateEntry for example, the get_date() method returns 2093-02-28. If I use the get() method it returns correct date as string but I won't be able to know for example if 3/6/93 means 03-06-1993 or 03-06-2093. Please do help.

Thanks.

teauxfu commented 3 years ago

Are you using the date_pattern attribute when making your DateEntry ? Perhaps I'm misunderstanding the problem

adamantonio commented 1 year ago

This is 2 years later but still a problem... here is some code that produces the error:

import datetime
import tkinter as tk
from tkinter import ttk
from tkcalendar import DateEntry

def get_date():
    print(cal.get_date())   # prints '2050-01-01'

root = tk.Tk()
cal = DateEntry(root)
old_date = datetime.date(1950, 1, 1)
cal.set_date(old_date)
cal.pack(padx=10, pady=10)
ttk.Button(root, text='Get date', command=get_date).pack(padx=10, pady=10)

root.mainloop()

Is the only solution to set a date pattern?