#!/usr/bin/env python
# This Python file uses the following encoding: utf-8
# !/usr/bin/env python
import smtplib

from django.core.mail import EmailMessage
from django.utils import timezone

import os

import django

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj_hkcm.settings")
django.setup()

import logging

FLOAT_DATA_FORMAT = '{:,.2f}'
SEND_EMAIL = True

log = logging.getLogger(__name__)
log.debug("")


class GeneralEmail:
    subject = ''
    content = ''

    def __init__(self):
        self.email_addr = 'pharrell.wang@zwap.hk'

    def send_email(self):

        msg = EmailMessage(self.subject, self.content, to=('pharrell.wang@zwap.hk',))

        try:
            msg.send()
        except smtplib.SMTPRecipientsRefused:
            ''

    def email_for_time_report(self, time_duration):
        self.subject = 'Time Report for HKCM'
        # now = timezone.localtime(timezone.now())
        # now = datetime.strftime(now, '%Y/%m/%d %H:%M:%S')
        # now = str(now)
        self.content = "hello Pharrell :          " + str(time_duration)
        # log.debug("Starting to send email!")
        self.send_email()
