This commit is contained in:
Daniel Tsvetkov 2020-01-06 10:30:58 +01:00
parent 3e45daec62
commit abd672ee12
4 changed files with 7 additions and 14 deletions

View File

@ -51,24 +51,14 @@
{% endfor %} {% endfor %}
</select> </select>
</form> </form>
{% for to_tz in to_tzs %}
{% endfor %}
</main> </main>
<script src="{{ url_for('static', filename='jquery.js') }}"></script> <script src="{{ url_for('static', filename='jquery.js') }}"></script>
<script src="{{ url_for('static', filename='jquery.debounce.js') }}"></script> <script src="{{ url_for('static', filename='jquery.debounce.js') }}"></script>
<script src="{{ url_for('static', filename='select2.js') }}"></script> <script src="{{ url_for('static', filename='select2.js') }}"></script>
<script src="{{ url_for('static', filename='main.js') }}"></script> <script src="{{ url_for('static', filename='main.js') }}"></script>
<script> <script>
var textarea = document.querySelector('textarea');
if (textarea)
textarea.addEventListener('keydown', autosize);
function autosize() {
var el = this;
setTimeout(function () {
el.style.cssText = 'height:auto; padding:0';
el.style.cssText = 'height:' + (el.scrollHeight + 30) + 'px';
}, 0);
}
$(document).ready(function () { $(document).ready(function () {
$('select').select2(); $('select').select2();

View File

@ -1,4 +1,3 @@
# ==================
from tww import dateparser_parse_dt, get_utcnow, dt_tz_translation, get_local_tzname_iana, get_local_tz_offset, \ from tww import dateparser_parse_dt, get_utcnow, dt_tz_translation, get_local_tzname_iana, get_local_tz_offset, \
tzname_to_tz_offset, get_s_since_epoch, time_to_emoji tzname_to_tz_offset, get_s_since_epoch, time_to_emoji

View File

@ -439,7 +439,7 @@ def query_to_dt(query):
def tzinfo_from_offset(offset: str) -> pytz.timezone: def tzinfo_from_offset(offset: str) -> pytz.timezone:
if ':' in offset: if ':' in offset:
offset = ''.join(offset.split(':')) offset = ''.join(offset.split(':'))
tznames = TZ_OFFSETS.get(offset) tznames = TZ_OFFSETS.get(offset, [])
for tzname in tznames: for tzname in tznames:
if tzname.startswith('Etc/GMT'): if tzname.startswith('Etc/GMT'):
return pytz.timezone(tzname) return pytz.timezone(tzname)

View File

@ -86,6 +86,10 @@ def parse_query(q):
@app.route("/") @app.route("/")
def home(): def home():
ctx = dict(all_tz=pytz.all_timezones)
q = request.args.get('q')
if q:
ctx["q_resp"] = jsonify(parse_query(q))
return render_template("home.html", all_tz=pytz.all_timezones) return render_template("home.html", all_tz=pytz.all_timezones)