Change time format
This commit is contained in:
parent
e2d02dae99
commit
d4c203c620
6 changed files with 70 additions and 2 deletions
12
chat_box/asgi.py
Normal file
12
chat_box/asgi.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
"""
|
||||||
|
ASGI entrypoint. Configures Django and then runs the application
|
||||||
|
defined in the ASGI_APPLICATION setting.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import django
|
||||||
|
from channels.routing import get_default_application
|
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dmoj.settings")
|
||||||
|
django.setup()
|
||||||
|
application = get_default_application()
|
|
@ -33,6 +33,7 @@ class ChatConsumer(AsyncWebsocketConsumer):
|
||||||
async def receive(self, text_data):
|
async def receive(self, text_data):
|
||||||
text_data_json = json.loads(text_data)
|
text_data_json = json.loads(text_data)
|
||||||
message = text_data_json['message']
|
message = text_data_json['message']
|
||||||
|
|
||||||
time = save_data_and_get_time(message)
|
time = save_data_and_get_time(message)
|
||||||
message['time'] = format_time(time)
|
message['time'] = format_time(time)
|
||||||
|
|
||||||
|
|
18
chat_box/migrations/0002_message_hidden.py
Normal file
18
chat_box/migrations/0002_message_hidden.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.12 on 2020-05-05 15:54
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('chat_box', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='message',
|
||||||
|
name='hidden',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='is hidden'),
|
||||||
|
),
|
||||||
|
]
|
18
chat_box/migrations/0003_auto_20200505_2306.py
Normal file
18
chat_box/migrations/0003_auto_20200505_2306.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.12 on 2020-05-05 16:06
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('chat_box', '0002_message_hidden'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='message',
|
||||||
|
name='hidden',
|
||||||
|
field=models.BooleanField(default=True, verbose_name='is hidden'),
|
||||||
|
),
|
||||||
|
]
|
18
chat_box/migrations/0004_auto_20200505_2336.py
Normal file
18
chat_box/migrations/0004_auto_20200505_2336.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 2.2.12 on 2020-05-05 16:36
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('chat_box', '0003_auto_20200505_2306'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='message',
|
||||||
|
name='hidden',
|
||||||
|
field=models.BooleanField(default=False, verbose_name='is hidden'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -11,7 +11,8 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def format_time(time):
|
def format_time(time):
|
||||||
return time.strftime('%H:%M %p %d-%m-%Y')
|
return time
|
||||||
|
#return time.strftime('%H:%M %p %d-%m-%Y')
|
||||||
|
|
||||||
|
|
||||||
def format_messages(messages):
|
def format_messages(messages):
|
||||||
|
@ -74,4 +75,4 @@ def delete_message(request):
|
||||||
|
|
||||||
return JsonResponse(ret)
|
return JsonResponse(ret)
|
||||||
|
|
||||||
return JsonResponse(ret)
|
return JsonResponse(ret)
|
||||||
|
|
Loading…
Reference in a new issue