コード例 #1
0
time_t
sameTimeNextDay(time_t t)
{
    const struct tm* tms = clocaltime(&t);
    struct tm tmc;
    memcpy(&tmc, tms, sizeof(struct tm));
    tmc.tm_mday++;
    tmc.tm_isdst = -1;
    if (mktime(&tmc) == -1)
        qFatal("Error at %s", time2ISO(t).toLatin1().constData());
    return mktime(&tmc);
}
コード例 #2
0
bool ReportXML::generate()
{
    if (!open())
        return false;

   if( ! project ) return false;
   QDomDocument doc( "Project" );
   doc.appendChild( doc.createProcessingInstruction(
        "xml", "version=\"1.0\" encoding=\"UTF-8\""));

   /* Create the Project xml representation */
   QDomElement proj = doc.createElement( "Project" );
   // FIXME: All projectIDs need to be saved here.
   proj.setAttribute( "Id", project->getCurrentId());
   proj.setAttribute( "WeekStart", project->getWeekStartsMonday() ? "Mon" : "Sun" );

   proj.appendChild( ReportXML::createXMLElem( doc, "Name", project->getName()));
   QString hStr = project->getVersion();
   if( !hStr.isEmpty() )
      proj.appendChild( ReportXML::createXMLElem( doc, "Version", hStr ));

   hStr = project->getCopyright();
   if( !hStr.isEmpty() )
      proj.appendChild( ReportXML::createXMLElem( doc, "Copyright", hStr ));

   proj.appendChild( ReportXML::createXMLElem( doc, "Priority",
                           QString::number(project->getPriority())));

   QDomElement tempElem;
   tempElem = ReportXML::createXMLElem( doc, "start",
                    QString::number(project->getStart()));
   tempElem.setAttribute( "humanReadable", time2ISO( project->getStart()));

   proj.appendChild( tempElem );

   tempElem = ReportXML::createXMLElem( doc, "end",
                    QString::number(project->getEnd()));
   tempElem.setAttribute( "humanReadable", time2ISO( project->getEnd()));
   proj.appendChild( tempElem );

   tempElem = ReportXML::createXMLElem( doc, "now",
                    QString::number(project->getNow()));
   tempElem.setAttribute( "humanReadable", time2ISO( project->getNow()));
   proj.appendChild( tempElem );

   doc.appendChild( proj );

   /* retrieve Tasklist from the project ... */
   TaskList taskList = project->getTaskList();
   /* ...and sort it */
   sortTaskList( taskList );

   /* do a loop over all tasks */
   for(TaskListIterator tli(taskList) ; *tli != 0; ++tli)
   {
       /* Child tasks will be generated recursively so we only need to
        * generate top-level tasks. */
       if((*tli)->getParent() == 0)
           proj.appendChild( (*tli)->xmlElement( doc ));
   }

   s << doc.toString();

    return close();
}