当前位置: 首页>>代码示例>>Python>>正文


Python TimeAgent.dt2str方法代码示例

本文整理汇总了Python中nell.utilities.TimeAgent.dt2str方法的典型用法代码示例。如果您正苦于以下问题:Python TimeAgent.dt2str方法的具体用法?Python TimeAgent.dt2str怎么用?Python TimeAgent.dt2str使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nell.utilities.TimeAgent的用法示例。


在下文中一共展示了TimeAgent.dt2str方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: receivers_schedule

# 需要导入模块: from nell.utilities import TimeAgent [as 别名]
# 或者: from nell.utilities.TimeAgent import dt2str [as 别名]
def receivers_schedule(request, *args, **kws):
    """
    For a given period, specified by a start date and duration, show
    all the receiver changes. Receiver changes are aligned with maintenance
    days.
    """

    # interpret the inputs
    startdate = request.GET.get("startdate", None)
    startdate = datetime.strptime(startdate, "%Y-%m-%d %H:%M:%S") if startdate else None

    duration = request.GET.get("duration", None)
    duration = int(duration) if duration else duration

    # use the input to get the basic rx schedule
    schedule = Receiver_Schedule.extract_schedule(startdate, duration)
    jsonschd = Receiver_Schedule.jsondict(schedule)

    # some clients also need the diff schedule
    diff = Receiver_Schedule.diff_schedule(schedule)
    jsondiff = Receiver_Schedule.jsondict_diff(diff).get("diff_schedule", None)

    # get the dates for maintenace that cover from the start of this
    # rcvr schedule.
    maintenance = [
        TimeAgent.dt2str(p.start)
        for p in Period.objects.filter(session__observing_type__type="maintenance", start__gte=startdate).order_by(
            "start"
        )
    ]

    # which receivers are temporarily unavailable?
    unavailable = [r.jsondict() for r in Receiver.objects.filter(available=False).order_by("freq_low")]

    # clients want to also know all the latest rcvrs
    rcvrs = [r.jsondict() for r in Receiver.objects.all().order_by("freq_low") if r.abbreviation != "NS"]
    return HttpResponse(
        json.dumps(
            {
                "schedule": jsonschd,
                "diff": jsondiff,
                "maintenance": maintenance,
                "unavailable": unavailable,
                "receivers": rcvrs,
            }
        ),
        mimetype="text/plain",
    )
开发者ID:,项目名称:,代码行数:50,代码来源:


注:本文中的nell.utilities.TimeAgent.dt2str方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。