How to use today method in argos

Best JavaScript code snippet using argos

email_subs.py

Source:email_subs.py Github

copy

Full Screen

1import os2from datetime import datetime, timedelta, timezone3from flask import Blueprint, request4from prometheus import metrics5routes = Blueprint('email-subs', __name__, url_prefix='/sub')6# noinspection PyPep87from sqlalchemy.exc import IntegrityError8from werkzeug.exceptions import Forbidden9from db import db10from models.caseDevelopments import CaseDevelopments11from models.email_subs import EmailSub, EmailSubsSchema, email_subs_schema, SubscribedCounties12from services.crypt_service import decrypt_message13# noinspection PyUnresolvedReferences14from psycopg2.errors import UniqueViolation15from models.risklayerPrognosis import RisklayerPrognosis16# noinspection PyPep817@routes.route('/', methods=['POST'])18def subscribe_new():19 """20 Add a new subscription21 """22 schema = EmailSubsSchema(exclude=['id', 'token'])23 try:24 new_sub = EmailSub(25 email=request.json['email'],26 email_hash=request.json['email'],27 lang=request.json['lang'],28 last_email_sent=datetime.now(timezone.utc)29 )30 new_sub.update_token()31 db.session.add(new_sub)32 db.session.flush()33 counties = []34 if 'counties' in request.json:35 counties = request.json['counties']36 for cjson in counties:37 c = SubscribedCounties()38 c.sub_id = new_sub.id39 c.ags = cjson['ags']40 db.session.add(c)41 db.session.commit()42 new_sub.send_email(43 subject='[CoronaVis] Verifiziere deine E-Mail-Adresse',44 sender='coronavis@dbvis.inf.uni-konstanz.de',45 template='mail/email_verification',46 id=new_sub.id,47 token=new_sub.token48 )49 return schema.dump(new_sub), 20150 except IntegrityError as ex:51 print(ex)52 assert isinstance(ex.orig, UniqueViolation) # proves the original exception53 db.session.rollback()54 # noinspection PyPep855 sub = db.session.query(EmailSub) \56 .filter(EmailSub.verified == False, EmailSub.email_hash == request.json['email']) \57 .first()58 # resend verification59 if sub is not None:60 sub.send_email(61 subject='[CoronaVis] Verifiziere deine E-Mail-Adresse',62 sender='coronavis@dbvis.inf.uni-konstanz.de',63 template='mail/email_verification',64 id=sub.id,65 token=sub.token66 )67 return schema.dump(sub), 20168@routes.route('/<sub_id>/<token>', methods=['GET'])69def get(sub_id, token):70 sub = __get_and_verify(sub_id, token)71 return email_subs_schema.dump(sub)72@routes.route('/<sub_id>/<token>', methods=['PATCH'])73def update(sub_id, token):74 sub = __get_and_verify(sub_id, token)75 if 'email' in request.json:76 sub.email = request.json['email']77 if 'lang' in request.json:78 sub.lang = request.json['lang']79 if 'verified' in request.json:80 sub.verified = request.json['verified']81 counties = []82 if 'counties' in request.json:83 counties = request.json['counties']84 db.session.query(SubscribedCounties).filter_by(sub_id=sub_id).delete()85 db.session.commit()86 for cjson in counties:87 c = SubscribedCounties()88 c.sub_id = sub_id89 c.ags = cjson['ags']90 db.session.add(c)91 db.session.commit()92 return email_subs_schema.dump(sub)93@routes.route('/<sub_id>/<token>', methods=['DELETE'])94def delete(sub_id, token):95 sub = __get_and_verify(sub_id, token)96 db.session.delete(sub)97 db.session.commit()98 return '', 20099@routes.route('/send-notifications', methods=['POST'])100@metrics.do_not_track()101def send_notifications():102 if not request.headers.get('X-API-KEY') == os.getenv('API_KEY'):103 f = Forbidden()104 f.description = 'Invalid API key'105 raise f106 __delete_unverified_emails()107 __rotate_tokens()108 c = CaseDevelopments('cases_per_county_and_day_risklayer')109 sevendaysago = (datetime.now(timezone.utc) - timedelta(days=8)).strftime('%Y-%m-%d')110 tomorrow = (datetime.now(timezone.utc) + timedelta(days=1)).strftime('%Y-%m-%d')111 de = c.get_country(from_time=sevendaysago, to_time=tomorrow, id_country='de', want_age_groups=False,112 want_geom=False)113 de_developments = de['properties']['developments']114 de_today = de_developments[-1]115 de_24h = de_developments[-2]116 de_72h = de_developments[-4]117 de_7d = de_developments[-8]118 prognosis = RisklayerPrognosis.query.order_by(RisklayerPrognosis.datenbestand.desc()).limit(1)[0]119 sql_result = db.engine.execute('''120 SELECT id, email, token, lang, c.ags, MAX(c.updated_at), 121 (CASE WHEN c.updated_at::date = e.last_email_sent::date THEN true ELSE false END) AS second_email122 FROM email_subs e123 JOIN email_subs_counties esc on e.id = esc.sub_id124 JOIN cases_lk_risklayer c ON esc.ags = c.ags125 WHERE c.updated_today = true AND c.date = now()::date126 AND c.updated_at > e.last_email_sent AND e.verified = true127 GROUP BY id, email, token, lang, c.ags, c.updated_at::date, e.last_email_sent::date128 ''')129 num_emails = 0130 for row in sql_result:131 lk = c.get_county(from_time=sevendaysago, to_time=tomorrow, id_county=row['ags'], want_age_groups=False,132 want_geom=False)133 lk_developments = lk['properties']['developments']134 lk_today = lk_developments[-1]135 lk_24h = lk_developments[-2]136 lk_72h = lk_developments[-4]137 lk_7d = lk_developments[-8]138 desc = lk['properties']['description']139 name = lk['properties']['name']140 sub: EmailSub = EmailSub.query.get_or_404(row['id'])141 sub.send_email(142 subject=f'[CoronaVis] Neue Daten für {desc} {name}',143 sender='coronavis@dbvis.inf.uni-konstanz.de',144 template='mail/county_notification_' + sub.lang,145 sub_id=row['id'],146 token=decrypt_message(row['token'].tobytes()),147 second_email=row['second_email'],148 county_id=row['ags'],149 county_desc=desc,150 county_name=name,151 county_population=round(lk_today['population']),152 county_last_updated=lk_today['last_updated'],153 county_cases_total=lk_today['cases'],154 county_cases_total_100k=round(__100k_change(lk_today['cases'], 0, lk_today['population']), 2),155 county_cases_24=__diff_str(lk_today['cases'] - lk_24h['cases']),156 county_cases_24_prc=__diff_str(__prc_change(lk_today['cases'], lk_24h['cases'])),157 county_cases_24_100k=__diff_str(__100k_change(lk_today['cases'], lk_24h['cases'], lk_today['population'])),158 county_cases_72=__diff_str(lk_today['cases'] - lk_72h['cases']),159 county_cases_72_prc=__diff_str(__prc_change(lk_today['cases'], lk_72h['cases'])),160 county_cases_72_100k=__diff_str(__100k_change(lk_today['cases'], lk_72h['cases'], lk_today['population'])),161 county_cases_7=__diff_str(lk_today['cases'] - lk_7d['cases']),162 county_cases_7_prc=__diff_str(__prc_change(lk_today['cases'], lk_7d['cases'])),163 county_cases_7_100k=__diff_str(__100k_change(lk_today['cases'], lk_7d['cases'], lk_today['population'])),164 county_deaths_total=lk_today['deaths'],165 county_deaths_total_100k=round(__100k_change(lk_today['deaths'], 0, lk_today['population']), 2),166 county_deaths_24=__diff_str(lk_today['deaths'] - lk_24h['deaths']),167 county_deaths_24_prc=__diff_str(__prc_change(lk_today['deaths'], lk_24h['deaths'])),168 county_deaths_24_100k=__diff_str(169 __100k_change(lk_today['deaths'], lk_24h['deaths'], lk_today['population'])),170 county_deaths_72=__diff_str(lk_today['deaths'] - lk_72h['deaths']),171 county_deaths_72_prc=__diff_str(__prc_change(lk_today['deaths'], lk_72h['deaths'])),172 county_deaths_72_100k=__diff_str(173 __100k_change(lk_today['deaths'], lk_72h['deaths'], lk_today['population'])),174 county_deaths_7=__diff_str(lk_today['deaths'] - lk_7d['deaths']),175 county_deaths_7_prc=__diff_str(__prc_change(lk_today['deaths'], lk_7d['deaths'])),176 county_deaths_7_100k=__diff_str(__100k_change(lk_today['deaths'], lk_7d['deaths'], lk_today['population'])),177 # Covid-19 Patients178 county_patients_total=lk_today['cases_covid'],179 county_patients_total_100k=round(__100k_change(lk_today['cases_covid'], 0, lk_today['population']), 2),180 county_patients_24=__diff_str(lk_today['cases_covid'] - lk_24h['cases_covid']),181 county_patients_24_prc=__diff_str(__prc_change(lk_today['cases_covid'], lk_24h['cases_covid'])),182 county_patients_24_100k=__diff_str(183 __100k_change(lk_today['cases_covid'], lk_24h['cases_covid'], lk_today['population'])),184 county_patients_72=__diff_str(lk_today['cases_covid'] - lk_72h['cases_covid']),185 county_patients_72_prc=__diff_str(__prc_change(lk_today['cases_covid'], lk_72h['cases_covid'])),186 county_patients_72_100k=__diff_str(187 __100k_change(lk_today['cases_covid'], lk_72h['cases_covid'], lk_today['population'])),188 county_patients_7=__diff_str(lk_today['cases_covid'] - lk_7d['cases_covid']),189 county_patients_7_prc=__diff_str(__prc_change(lk_today['cases_covid'], lk_7d['cases_covid'])),190 county_patients_7_100k=__diff_str(191 __100k_change(lk_today['cases_covid'], lk_7d['cases_covid'], lk_today['population'])),192 # Covid-19 Patients Ventilated193 county_patients_ventilated_total=lk_today['cases_covid_ventilated'],194 county_patients_ventilated_total_100k=round(195 __100k_change(lk_today['cases_covid_ventilated'], 0, lk_today['population']), 2),196 county_patients_ventilated_24=__diff_str(197 lk_today['cases_covid_ventilated'] - lk_24h['cases_covid_ventilated']),198 county_patients_ventilated_24_prc=__diff_str(199 __prc_change(lk_today['cases_covid_ventilated'], lk_24h['cases_covid_ventilated'])),200 county_patients_ventilated_24_100k=__diff_str(201 __100k_change(202 lk_today['cases_covid_ventilated'], lk_24h['cases_covid_ventilated'], lk_today['population'])),203 county_patients_ventilated_72=__diff_str(204 lk_today['cases_covid_ventilated'] - lk_72h['cases_covid_ventilated']),205 county_patients_ventilated_72_prc=__diff_str(206 __prc_change(lk_today['cases_covid_ventilated'], lk_72h['cases_covid_ventilated'])),207 county_patients_ventilated_72_100k=__diff_str(208 __100k_change(209 lk_today['cases_covid_ventilated'], lk_72h['cases_covid_ventilated'], lk_today['population'])),210 county_patients_ventilated_7=__diff_str(211 lk_today['cases_covid_ventilated'] - lk_7d['cases_covid_ventilated']),212 county_patients_ventilated_7_prc=__diff_str(213 __prc_change(lk_today['cases_covid_ventilated'], lk_7d['cases_covid_ventilated'])),214 county_patients_ventilated_7_100k=__diff_str(215 __100k_change(216 lk_today['cases_covid_ventilated'], lk_7d['cases_covid_ventilated'], lk_today['population'])),217 # Bed Occupancy218 county_bed_occupancy_total=f"{lk_today['beds_occupied']}/{lk_today['beds_total']}",219 county_bed_occupancy_total_prc=round((lk_today['beds_occupied'] / lk_today['beds_total']) * 10000) / 100,220 county_bed_occupancy_24=f"{__diff_str(lk_today['beds_occupied'] - lk_24h['beds_occupied'])}/{__diff_str(lk_today['beds_total'] - lk_24h['beds_total'])}",221 county_bed_occupancy_24_prc=__diff_str(__prc_change(lk_today['beds_occupied'] / lk_today['beds_total'],222 lk_24h['beds_occupied'] / lk_24h['beds_total'])),223 county_bed_occupancy_72=f"{__diff_str(lk_today['beds_occupied'] - lk_72h['beds_occupied'])}/{__diff_str(lk_today['beds_total'] - lk_72h['beds_total'])}",224 county_bed_occupancy_72_prc=__diff_str(__prc_change(lk_today['beds_occupied'] / lk_today['beds_total'],225 lk_72h['beds_occupied'] / lk_72h['beds_total'])),226 county_bed_occupancy_7=f"{__diff_str(lk_today['beds_occupied'] - lk_7d['beds_occupied'])}/{__diff_str(lk_today['beds_total'] - lk_7d['beds_total'])}",227 county_bed_occupancy_7_prc=__diff_str(__prc_change(lk_today['beds_occupied'] / lk_today['beds_total'],228 lk_7d['beds_occupied'] / lk_7d['beds_total'])),229 num_counties_reported=de_today['num_counties_reported'],230 num_counties_total=de_today['num_counties_total'],231 prognosis=round(prognosis.prognosis),232 country_population=round(de_today['population']),233 country_last_updated=de_today['last_updated'],234 country_cases_total=de_today['cases'],235 country_cases_total_100k=round(__100k_change(de_today['cases'], 0, de_today['population']), 2),236 country_cases_24=__diff_str(de_today['cases'] - de_24h['cases']),237 country_cases_24_prc=__diff_str(__prc_change(de_today['cases'], de_24h['cases'])),238 country_cases_24_100k=__diff_str(__100k_change(de_today['cases'], de_24h['cases'], de_today['population'])),239 country_cases_72=__diff_str(de_today['cases'] - de_72h['cases']),240 country_cases_72_prc=__diff_str(__prc_change(de_today['cases'], de_72h['cases'])),241 country_cases_72_100k=__diff_str(__100k_change(de_today['cases'], de_72h['cases'], de_today['population'])),242 country_cases_7=__diff_str(de_today['cases'] - de_7d['cases']),243 country_cases_7_prc=__diff_str(__prc_change(de_today['cases'], de_7d['cases'])),244 country_cases_7_100k=__diff_str(__100k_change(de_today['cases'], de_7d['cases'], de_today['population'])),245 country_deaths_total=de_today['deaths'],246 country_deaths_total_100k=round(__100k_change(de_today['deaths'], 0, de_today['population']), 2),247 country_deaths_24=__diff_str(de_today['deaths'] - de_24h['deaths']),248 country_deaths_24_prc=__diff_str(__prc_change(de_today['deaths'], de_24h['deaths'])),249 country_deaths_24_100k=__diff_str(250 __100k_change(de_today['deaths'], de_24h['deaths'], de_today['population'])),251 country_deaths_72=__diff_str(de_today['deaths'] - de_72h['deaths']),252 country_deaths_72_prc=__diff_str(__prc_change(de_today['deaths'], de_72h['deaths'])),253 country_deaths_72_100k=__diff_str(254 __100k_change(de_today['deaths'], de_72h['deaths'], de_today['population'])),255 country_deaths_7=__diff_str(de_today['deaths'] - de_7d['deaths']),256 country_deaths_7_prc=__diff_str(__prc_change(de_today['deaths'], de_7d['deaths'])),257 country_deaths_7_100k=__diff_str(258 __100k_change(de_today['deaths'], de_7d['deaths'], de_today['population'])),259 # Covid-19 Patients260 country_patients_total=de_today['cases_covid'],261 country_patients_total_100k=round(__100k_change(de_today['cases_covid'], 0, de_today['population']), 2),262 country_patients_24=__diff_str(de_today['cases_covid'] - de_24h['cases_covid']),263 country_patients_24_prc=__diff_str(__prc_change(de_today['cases_covid'], de_24h['cases_covid'])),264 country_patients_24_100k=__diff_str(265 __100k_change(de_today['cases_covid'], de_24h['cases_covid'], de_today['population'])),266 country_patients_72=__diff_str(de_today['cases_covid'] - de_72h['cases_covid']),267 country_patients_72_prc=__diff_str(__prc_change(de_today['cases_covid'], de_72h['cases_covid'])),268 country_patients_72_100k=__diff_str(269 __100k_change(de_today['cases_covid'], de_72h['cases_covid'], de_today['population'])),270 country_patients_7=__diff_str(de_today['cases_covid'] - de_7d['cases_covid']),271 country_patients_7_prc=__diff_str(__prc_change(de_today['cases_covid'], de_7d['cases_covid'])),272 country_patients_7_100k=__diff_str(273 __100k_change(de_today['cases_covid'], de_7d['cases_covid'], de_today['population'])),274 # Covid-19 Patients Ventilated275 country_patients_ventilated_total=de_today['cases_covid_ventilated'],276 country_patients_ventilated_total_100k=round(277 __100k_change(de_today['cases_covid_ventilated'], 0, de_today['population']), 2),278 country_patients_ventilated_24=__diff_str(279 de_today['cases_covid_ventilated'] - de_24h['cases_covid_ventilated']),280 country_patients_ventilated_24_prc=__diff_str(281 __prc_change(de_today['cases_covid_ventilated'], de_24h['cases_covid_ventilated'])),282 country_patients_ventilated_24_100k=__diff_str(283 __100k_change(284 de_today['cases_covid_ventilated'], de_24h['cases_covid_ventilated'], de_today['population'])),285 country_patients_ventilated_72=__diff_str(286 de_today['cases_covid_ventilated'] - de_72h['cases_covid_ventilated']),287 country_patients_ventilated_72_prc=__diff_str(288 __prc_change(de_today['cases_covid_ventilated'], de_72h['cases_covid_ventilated'])),289 country_patients_ventilated_72_100k=__diff_str(290 __100k_change(291 de_today['cases_covid_ventilated'], de_72h['cases_covid_ventilated'], de_today['population'])),292 country_patients_ventilated_7=__diff_str(293 de_today['cases_covid_ventilated'] - de_7d['cases_covid_ventilated']),294 country_patients_ventilated_7_prc=__diff_str(295 __prc_change(de_today['cases_covid_ventilated'], de_7d['cases_covid_ventilated'])),296 country_patients_ventilated_7_100k=__diff_str(297 __100k_change(298 de_today['cases_covid_ventilated'], de_7d['cases_covid_ventilated'], de_today['population'])),299 # Bed Occupancy300 country_bed_occupancy_total=f"{de_today['beds_occupied']}/{de_today['beds_total']}",301 country_bed_occupancy_total_prc=round((de_today['beds_occupied'] / de_today['beds_total']) * 10000) / 100,302 country_bed_occupancy_24=f"{__diff_str(de_today['beds_occupied'] - de_24h['beds_occupied'])}/{__diff_str(de_today['beds_total'] - de_24h['beds_total'])}",303 country_bed_occupancy_24_prc=__diff_str(__prc_change(de_today['beds_occupied'] / de_today['beds_total'],304 de_24h['beds_occupied'] / de_24h['beds_total'])),305 country_bed_occupancy_72=f"{__diff_str(de_today['beds_occupied'] - de_72h['beds_occupied'])}/{__diff_str(de_today['beds_total'] - de_72h['beds_total'])}",306 country_bed_occupancy_72_prc=__diff_str(__prc_change(de_today['beds_occupied'] / de_today['beds_total'],307 de_72h['beds_occupied'] / de_72h['beds_total'])),308 country_bed_occupancy_7=f"{__diff_str(de_today['beds_occupied'] - de_7d['beds_occupied'])}/{__diff_str(de_today['beds_total'] - de_7d['beds_total'])}",309 country_bed_occupancy_7_prc=__diff_str(__prc_change(de_today['beds_occupied'] / de_today['beds_total'],310 de_7d['beds_occupied'] / de_7d['beds_total']))311 )312 db.session.add(sub)313 db.session.commit()314 num_emails += 1315 return f'emails sent {num_emails}', 200316def __prc_change(new, old) -> float:317 if old == 0:318 return 0319 return ((new - old) / old) * 100320def __100k_change(new, old, pop) -> float:321 return ((new - old) / pop) * 100000322def __diff_str(val) -> str:323 if val > 0:324 return '+' + str(round(val, 2))325 return str(round(val, 2))326def __get_and_verify(sub_id, token) -> EmailSub:327 sub = EmailSub.query.get_or_404(sub_id)328 if not sub.verify_token(token):329 b = Forbidden()330 b.description = 'invalid token'331 raise b332 return sub333def __rotate_tokens():334 since = datetime.now(timezone.utc) - timedelta(hours=72)335 subs = db.session.query(EmailSub).filter(EmailSub.token_updated < since).all()336 for s in subs:337 s.update_token()338 db.session.commit()339def __delete_unverified_emails():340 since = datetime.now(timezone.utc) - timedelta(hours=1)341 db.session.query(EmailSub).filter(EmailSub.last_email_sent < since, EmailSub.verified == False).delete()...

Full Screen

Full Screen

daterange.js

Source:daterange.js Github

copy

Full Screen

...284 switch (dateRangeKey) {285 case goog.date.DateRange.StandardDateRangeKeys.YESTERDAY:286 return goog.date.DateRange.yesterday(opt_today);287 case goog.date.DateRange.StandardDateRangeKeys.TODAY:288 return goog.date.DateRange.today(opt_today);289 case goog.date.DateRange.StandardDateRangeKeys.LAST_7_DAYS:290 return goog.date.DateRange.last7Days(opt_today);291 case goog.date.DateRange.StandardDateRangeKeys.THIS_MONTH:292 return goog.date.DateRange.thisMonth(opt_today);293 case goog.date.DateRange.StandardDateRangeKeys.LAST_MONTH:294 return goog.date.DateRange.lastMonth(opt_today);295 case goog.date.DateRange.StandardDateRangeKeys.THIS_WEEK:296 return goog.date.DateRange.thisWeek(opt_today);297 case goog.date.DateRange.StandardDateRangeKeys.LAST_WEEK:298 return goog.date.DateRange.lastWeek(opt_today);299 case goog.date.DateRange.StandardDateRangeKeys.LAST_BUSINESS_WEEK:300 return goog.date.DateRange.lastBusinessWeek(opt_today);301 case goog.date.DateRange.StandardDateRangeKeys.ALL_TIME:302 return goog.date.DateRange.allTime(opt_today);...

Full Screen

Full Screen

todayTime.js

Source:todayTime.js Github

copy

Full Screen

1function getYearOne(){//获得当年第一天2 var today=new Date();3 year = today.getFullYear();4 5 var iniStartTime = year+"-01-01";6 return iniStartTime;7}89//获得当月第一天10function getMonthOne(){//获得今天11 var today=new Date();12 year = today.getFullYear();13 14 month = today.getMonth()+1;15 if(month<10){month="0"+month;}16 17 var iniEndTime = year+"-"+month+"-01";18 return iniEndTime;19}2021function getToday(){//获得今天22 23 var today=new Date();24 year = today.getFullYear();25 26 month = today.getMonth()+1;27 if(month<10){month="0"+month;}28 29 date = today.getDate();30 if(date<10){date="0"+date;}31 32 var iniEndTime = year+"-"+month+"-"+date;33 return iniEndTime;34}3536function getMonthSelect(monthId){//获得当月37 var today=new Date();38 month = today.getMonth()+1;39/* if(month<10){month="0"+month;}40 $(monthId).val(month);*/4142 43 $(monthId).find("option").each(function(){44 if( month == $(this).val() ){45 $(this).attr({selected:"selected"})46 }47 })4849 return month;50}5152function getYearSelect(yearId){53 var today=new Date();54 var year = today.getFullYear();55 for(var i=year;i>=2012;i--){56 $(yearId).append("<option value='"+i+"'>"+i+"</option>");57 }58}5960function getYearSelect2017over(yearId){61 var today=new Date();62 var year = today.getFullYear();63 for(var i=year;i>=2017;i--){64 $(yearId).append("<option value='"+i+"'>"+i+"</option>");65 }66}6768function getSelectToday(todayId){//选中今天69 var today=new Date();70 year = today.getFullYear();71 72 month = today.getMonth()+1;73 if(month<10){month="0"+month;}74 75 date = today.getDate();76 if(date<10){date="0"+date;}77 78 var iniEndTime = year+"-"+month+"-"+date;79 $(todayId).val(iniEndTime); //结束时间赋值80}8182function getYearFlagOrNo(startTime,endTime){83 startTime = startTime.substr(0, 4);84 endTime = endTime.substr(0, 4);85 if(startTime!=endTime){86 alert("时间选取不能跨年!");87 return false;88 }else{89 return true;90 }91}9293function showtime(){94 var today,hour,second,minute,year,month,date;95 var strDate ;96 today=new Date();97 var n_day = today.getDay();98 switch (n_day){99 case 0:{100 strDate = "星期日"101 }break;102 case 1:{103 strDate = "星期一"104 }break;105 case 2:{106 strDate ="星期二"107 }break;108 case 3:{109 strDate = "星期三"110 }break;111 case 4:{112 strDate = "星期四"113 }break;114 case 5:{115 strDate = "星期五"116 }break;117 case 6:{118 strDate = "星期六"119 }break;120 case 7:{121 strDate = "星期日"122 }break;123 }124 year = today.getFullYear();125 month = today.getMonth()+1;126 date = today.getDate();127 hour = today.getHours();128 minute =today.getMinutes();129 second = today.getSeconds();130 document.getElementById('time').innerHTML = year + "年" + month + "月" + date + "日 " + strDate +" " + hour + ":" + minute + ":" + second; //显示时间131 setTimeout("showtime();", 1000); //设定函数自动执行时间为 1000 ms(1 s) ...

Full Screen

Full Screen

Helperfunctions.js

Source:Helperfunctions.js Github

copy

Full Screen

1export function first2(date){2 return ('0' + date).split('').reverse().slice(0,2).reverse().join('')3}4export function lessThanDate(date,today){5 let [dateYear,dateMonth,dateDay] = date.split('-').map(el => Number(el))6 let [todayYear,todayMonth,todayDay] = today.split('-').map(el => Number(el))7 if(todayYear > dateYear) return true8 if(todayYear == todayYear){9 if(todayMonth > dateMonth) return true10 if(todayMonth == dateMonth){11 if(todayDay > dateDay) return true12 }13 }14 return false15}16export function InThisWeek(date){17 let noOfDays = [31,28,31,30,31,30,31,31,30,31,30,31]18 let todayWeekDate = new Date().getDay()19 let [year,month,day] = [new Date().getFullYear(),new Date().getMonth() + 1,new Date().getDate()]20 let sday = (noOfDays[month - 2] + day-todayWeekDate) % noOfDays[month - 2]21 let smonth = sday == day-todayWeekDate ? month : month - 122 let syear = smonth < 0 ? year - 1 : year23 let stday = (noOfDays[month - 1] + (day + (6 - todayWeekDate))) % noOfDays[month - 1]24 let stmonth = stday == day + (6 - todayWeekDate) ? month : month + 125 let styear = stmonth > 12 ? year + 1 : year26 console.log('sunday',[sday,smonth,syear])27 console.log('saturday',[stday,stmonth,styear])28 let [dateYear,dateMonth,dateDay] = date.split('-').map(el => Number(el))29 if(dateYear > syear && dateYear < styear) return true30 if(dateYear == syear && dateYear == styear){31 if(dateMonth > smonth && dateMonth < stmonth) return true32 if(dateMonth == stmonth && dateMonth == smonth){33 if(dateDay >= sday && dateDay <= stday) return true34 }35 if(dateMonth == smonth && dateDay > sday) return true36 if(dateMonth == stmonth && dateDay < stday) return true37 }38 return false39}40export function InThisMonth(date){41 return date.split('-')[1] == (new Date().getMonth() + 1)42}43export function AfterToday(date){44 let [dateYear,dateMonth,dateDay] = date.split('-').map(el => Number(el))45 let [todayYear,todayMonth,todayDay] = `${new Date().getFullYear()}-${first2(new Date().getMonth() + 1)}-${first2(new Date().getDate())}`.split('-').map(el => Number(el))46 if(todayYear < dateYear) return true47 if(todayYear == dateYear){48 if(todayMonth < dateMonth) return true49 if(todayMonth == dateMonth){50 if(todayDay < dateDay) return true51 }52 }53 return false...

Full Screen

Full Screen

02_date.py

Source:02_date.py Github

copy

Full Screen

1# Python date type2from datetime import date, datetime3today = date.today()4print(today, type(today)) #datetime.date5print('년도: {}, 월: {}, 일: {}'. format(today.year, today.month, today.day))6# 날짜 및 시간7my_datetime = datetime.today()8print(my_datetime)9print('현재 {}시, {}분, {}초, {}...'.format(my_datetime.hour, my_datetime.minute, my_datetime.second, my_datetime.microsecond))10from datetime import date, datetime, timedelta11from dateutil. relativedelta import relativedelta12today = date.today()13yesterday = timedelta(days=-1)14print('yesterday: {}'.format(today+yesterday))15# timedelta()16# weeks, days, hours, minutes, seconds -> possible17# years, months -> impossible18days= relativedelta(months=-2)19print('two months before: {}'.format(today+days))20# 특정 날짜 객체를 생성21from dateutil.parser import parse22myDay = parse('2020-08-11')23print(myDay) # 2020-08-11 00:00:0024myDay = datetime(2020,8,11)25print(myDay) # 2020-08-11 00:00:0026#strftime (날짜를 문자열형태로 포맷 지정)27#strptime (문자열을 날짜형태로)28today=datetime.today()29print('{}'.format(today.strftime("%m-%d-%y"))) # 09-25-2030print('{}'.format(today.strftime("%m-%d-%Y"))) # 09-25-202031str='2020, 08, 11 - 13:14:20'32my_str = datetime.strptime(str,'%Y, %m, %d - %H:%M:%S')33print(type(my_str))...

Full Screen

Full Screen

test.py

Source:test.py Github

copy

Full Screen

2import datetime3import calendar4from datetime import date5def main():6 today = date.today()7 print("Clocked out on ", today) 8 print("Clocked out on ", today.month, "-", today.day, "-", today.year)9main()10# date object of today's date11#today = date.today() 12#print("Current year:", today.year)13#print("Current month:", today.month)...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var today = require('argosy-pattern-today')();3var service = argosy();4service.pipe(today()).pipe(service);5service.accept({ today: true }, function (args, cb) {6 cb(null, args);7});8service.listen(3000);9var argosy = require('argosy');10var today = require('argosy-pattern-today')();11var service = argosy();12service.pipe(today()).pipe(service);13service.accept({ today: true }, function (args, cb) {14 cb(null, args);15});16service.listen(3001);17var argosy = require('argosy');18var today = require('argosy-pattern-today')();19var service = argosy();20service.pipe(today()).pipe(service);21service.accept({ today: true }, function (args, cb) {22 cb(null, args);23});24service.listen(3002);25var argosy = require('argosy');26var today = require('argosy-pattern-today')();27var service = argosy();28service.pipe(today()).pipe(service);29service.accept({ today: true }, function (args, cb) {30 cb(null, args);31});32service.listen(3003);33var argosy = require('argosy');34var today = require('argosy-pattern-today')();35var service = argosy();36service.pipe(today()).pipe(service);37service.accept({ today: true }, function (args, cb) {38 cb(null, args);39});40service.listen(3004);41var argosy = require('argosy');42var today = require('argosy-pattern-today')();43var service = argosy();44service.pipe(today()).pipe(service);45service.accept({ today: true }, function (args, cb) {46 cb(null, args);47});48service.listen(3005);

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var today = require('argosy-today');3var todayService = today();4var argosyService = argosy();5argosyService.pipe(todayService).pipe(argosyService);6argosyService.act('role:today', function (err, result) {7 console.log(result);8});9var argosy = require('argosy');10var today = require('argosy-today');11var todayService = today();12var argosyService = argosy();13argosyService.pipe(todayService).pipe(argosyService);14argosyService.act('role:today', function (err, result) {15 console.log(result);16});17var argosy = require('argosy');18var today = require('argosy-today');19var todayService = today({20});21var argosyService = argosy();22argosyService.pipe(todayService).pipe(argosyService);23argosyService.act('role:today', function (err, result) {24 console.log(result);25});26var argosy = require('argosy');27var today = require('argosy-today');28var todayService = today({29});30var argosyService = argosy();31argosyService.pipe(todayService).pipe(argosyService);32argosyService.act('role:today', function (err, result) {33 console.log(result);34});35var argosy = require('argosy');36var today = require('argosy

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var today = require('argosy-pattern/today')3var todayService = today({4 today: function (callback) {5 callback(null, new Date())6 }7})8var service = argosy()9service.use(todayService)10service.listen(8000)11var argosy = require('argosy')12var today = require('argosy-pattern/today')13var service = argosy()14service.today(function (err, date) {15 console.log(date)16})

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy')2var today = require('argosy-pattern/today')3var patterns = require('argosy-pattern')4var service = argosy()5service.accept(today(function (date) {6}))7service.pipe(argosy.pattern({8})).pipe(service)9service.on('today', function (date) {10 console.log(date)11})12#### `argosy.pattern(pattern)`13var argosy = require('argosy')14var today = require('argosy-pattern/today')15var patterns = require('argosy-pattern')16var service = argosy()17service.pipe(argosy.pattern({18})).pipe(service)19service.on('today', function (date) {20 console.log(date)21})22#### `argosy.pattern(pattern, handler)`23var argosy = require('argosy')24var today = require('argosy-pattern/today')25var patterns = require('argosy-pattern')26var service = argosy()27service.pipe(argosy.pattern({28}, function (pattern, cb) {29 cb(null, new Date())30})).pipe(service)31service.on('today', function (date) {32 console.log(date)33})34#### `argosy.pattern(pattern, handler, options)`35var argosy = require('argosy')36var today = require('argosy-pattern/today')37var patterns = require('argosy-pattern')38var service = argosy()39service.pipe(argosy.pattern({40}, function (pattern,

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var today = argosy.patterns.today;3argosy().use(today()).listen(3000);4var argosy = require('argosy');5var today = argosy.patterns.today;6argosy().use(today()).listen(3000);7var argosy = require('argosy');8var today = argosy.patterns.today;9argosy().use(today()).listen(3000);10var argosy = require('argosy');11var today = argosy.patterns.today;12argosy().use(today()).listen(3000);13var argosy = require('argosy');14var today = argosy.patterns.today;15argosy().use(today()).listen(3000);16var argosy = require('argosy');17var today = argosy.patterns.today;18argosy().use(today()).listen(3000);19var argosy = require('argosy');20var today = argosy.patterns.today;21argosy().use(today()).listen(3000);22var argosy = require('argosy');23var today = argosy.patterns.today;24argosy().use(today()).listen(3000);25var argosy = require('argosy');26var today = argosy.patterns.today;27argosy().use(today()).listen(3000);

Full Screen

Using AI Code Generation

copy

Full Screen

1const argosy = require('argosy')2const today = require('argosy-pattern/today')3const pattern = today('date')4argosy()5 .use(pattern, () => new Date())6 .act('date', (err, date) => {7 console.log(date)8 })9### `today(pattern, [options])`10### `yesterday(pattern, [options])`11### `tomorrow(pattern, [options])`12### `date(pattern, [options])`

Full Screen

Using AI Code Generation

copy

Full Screen

1var argosy = require('argosy');2var today = argosy.patterns.today;3var pattern = today();4var assert = require('assert');5var service = argosy();6service.accept(pattern, function (msg, cb) {7 cb(null, msg);8});9service.listen();10service.act(pattern, function (err, msg) {11 assert.ok(msg);12 assert.equal(msg.day, new Date().getDate());13 assert.equal(msg.month, new Date().getMonth() + 1);14 assert.equal(msg.year, new Date().getFullYear());15 console.log('test passed');16});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run argos automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful