Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
streamlit-datetime-picker
Advanced tools
streamlit-datetime-picker
is the input component to use with Streamlit.
pip install streamlit-datetime-picker
create an example.py file
import streamlit as st
from streamlit_datetime_picker import date_time_picker, date_range_picker
dt = date_time_picker('Date Time Input')
st.write(f"DateTimeInput: {dt}")
(start, end) = date_range_picker()
st.write(f"DateRangeInput: From {start} to {end}")
run streamlit
streamlit run example.py
As streamlit rerun the whole python script whenever a component value is changed, thus cannot use datetime.now()
directly.
Can make use of the st.session_state
to store the current date and time so that the initial value doens't change whenever the page is reloaded.
from datetime import datetime, timedelta
def now() -> datetime:
if 'now' not in st.session_state:
st.session_state['now'] = datetime.now().astimezone()
return st.session_state['now']
def clearNow():
if 'now' in st.session_state:
del st.session_state['now']
date_time_picker
and date_range_picker
will change color depend on your streamlit theme
Switch in different types of picker
This property is only application is datetime
and date
picker
Place holder text will display when the value is not selected
dt = date_time_picker(placeholder='Enter your birthday')
Allow empty for the date_range_picker
. It's useful when you need to keep the "to date".
Provide None at the initial value will provide
start, end = date_range_picker(value=(now()-timedelta(7), None), placeholder=('Start datetime', 'Till Now'))
end = now() if end is None else end
st.write(f"DateRangeInput: From **{start}** to **{end}**")
Custom format can be set. Format string syntax can reference in dayjs documentation
dt = date_time_picker(format='DD-MMM-YYYY HH:mm:ss')
allowClear=False
will not allow user to clear the date and time value.
dt = date_time_picker(value=now(), allowClear=False)
start, end = date_range_picker(value=(now()-timedelta(7), now()), allowClear=False)
Limit the range of dates by providing minDate
and maxDate
dt = date_time_picker(value=now(), minDate=now()-timedelta(7), maxDate=now()+timedelta(7))
start, end = date_range_picker(value=(now()-timedelta(7), now()), minDate=now()-timedelta(7), maxDate=now()+timedelta(7))
Disabled selected dates
disabledDates = [now()-timedelta(3), now()+timedelta(2)]
dt = date_time_picker(value=now(), disabledDates=disabledDates)
start, end = date_range_picker(value=(now()-timedelta(1), now()), disabledDates=disabledDates)
We can set preset values to date_time_picker
and date_range_picker
to improve user experience.
nowVal = now()
dt = date_time_picker(value=nowVal, presets=[Preset[datetime]('24hr ago', nowVal-timedelta(1)), Preset[datetime]('A week ago', nowVal-timedelta(7))])
start, end = date_range_picker(value=(nowVal-timedelta(1), now()), presets=[Preset[Tuple[datetime, datetime]]('This week', (nowVal-timedelta(1+nowVal.weekday()), nowVal+timedelta(6-nowVal.weekday())))])
Size: The input box comes in three sizes. middle
, small
and large
are avaliable.
Variant: There are outlined
, filled
and borderless
variants to choose from.
Status: status could be error
or warning
FAQs
Streamlit Date and Time Picker
We found that streamlit-datetime-picker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.