Exemplo n.º 1
0
double
Date::getSince(Date &lag, const char *ref)
{
    // this wrapping method returns the time lag since date.
    // valid expr for desc: seconds, minutes, hours, days, months year
    // If date is omitted, a reference date must have been
    // set previously.

    std::string sRef(ref);

    if( sRef.size() > 0 )
        setDate(sRef);

    double dJul=lag.getJulianDay() - getJulianDay();

    if( unitStr.substr(0,1) == "y" )
    {   // ToDo
        return 0.;
    }
    else if( unitStr.substr(0,2) == "mo" )
    {   // ToDo
        return 0.;
    }
    else if( unitStr.substr(0,4) == "day" )
        return static_cast<double>(dJul);
    else if( unitStr.substr(0,1) == "h" )
        return static_cast<double>(dJul*24.);
    else if( unitStr.substr(0,2) == "mi" )
        return static_cast<double>(dJul*24.*60.);
    else if( unitStr.substr(0,1) == "s" )
        return static_cast<double>(dJul*24.*60.*60.);

    return 0.;  // a return statement here is required for the xlc++
}
Exemplo n.º 2
0
// Check for a matching named reference.
//
static dbref absolute_named_reference(UTF8 *name)
{
    if (  NULL == name
       || '\0' == name[0])
    {
        return NOTHING;
    }

    mux_string sRef(name);
    if ('_' != name[0])
    {
        sRef.append(T("."));
        sRef.append(md.player);
    }

    UTF8 *pReferenceName = alloc_lbuf("absolute_named_reference");
    size_t nReferenceName = 0;
    nReferenceName = sRef.export_TextPlain(pReferenceName);

    struct reference_entry *result = (reference_entry *)hashfindLEN(
        pReferenceName, nReferenceName, &mudstate.reference_htab);
    free_lbuf(pReferenceName);

    if (  NULL != result
       && Good_obj(result->target))
    {
        return result->target;
    }
    else
    {
        return NOTHING;
    }
}