Changeset f9bb68 in git


Ignore:
Timestamp:
Aug 27, 2010, 10:15:09 AM (14 years ago)
Author:
Frank Seelisch <seelisch@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd25190065115c859833252500a64cfb7b11e3a50')
Children:
555b030713519677d5c1d72e1cdfacc419cc4bdc
Parents:
5cb9ecd7f9c68100731d2b46abd492589627c598
Message:
implemented and documented new command 'datetime' for local date/time as string

git-svn-id: file:///usr/local/Singular/svn/trunk@13152 2c84dea3-7e68-4137-9b89-c4e89433aadc
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Singular/iparith.cc

    r5cb9ec rf9bb68  
    7272#include <Singular/ipshell.h>
    7373#include <kernel/mpr_inout.h>
     74
     75#include <kernel/timer.h>
    7476
    7577#ifdef HAVE_PLURAL
     
    442444
    443445/* set sys vars*/
     446  { "datetime",    0, DATETIME ,          SYSVAR},
    444447  { "degBound",    0, VMAXDEG ,           SYSVAR},
    445448  { "echo",        0, VECHO ,             SYSVAR},
  • Singular/misc_ip.cc

    r5cb9ec rf9bb68  
    220220  if (nlIsZero(nn) || (nnAsInt != 0))
    221221  {
    222     nlDelete(&nn,NULL):
     222    nlDelete(&nn,NULL);
    223223    L->m[0].rtyp = INT_CMD;
    224224    L->m[0].data = (void *)nnAsInt;
  • Singular/subexpr.cc

    r5cb9ec rf9bb68  
    308308        }
    309309        break;
     310      case DATETIME: 
    310311      case STRING_CMD:
    311312        omFree((ADDRESS)data);
     
    357358      case VCOLMAX:
    358359      case VTIMER:
     360      case DATETIME:
    359361#ifdef HAVE_RTIMER
    360362      case VRTIMER:
     
    390392      case VCOLMAX:
    391393      case VTIMER:
     394      case DATETIME:
    392395#ifdef HAVE_RTIMER
    393396      case VRTIMER:
     
    569572    else if (rtyp==LIB_CMD)
    570573      x=(void *)omStrDup((char *)Data());
     574    else if (rtyp==DATETIME)
     575      x=(void *)omStrDup((char *)Data());
    571576    else if ((rtyp==VMINPOLY)&& (currRing->minpoly!=NULL)&&(!rField_is_GF()))
    572577      x=(void *)nCopy(currRing->minpoly);
     
    852857        return INT_CMD;
    853858      case LIB_CMD:
     859      case DATETIME:
    854860        return STRING_CMD;
    855861      case VMINPOLY:
     
    972978      case VCOLMAX:    return (void *)colmax;
    973979      case VTIMER:     return (void *)getTimer();
     980      case DATETIME:   return (void *)dateTime();
    974981#ifdef HAVE_RTIMER
    975982      case VRTIMER:    return (void *)getRTimer();
  • Singular/tok.h

    r5cb9ec rf9bb68  
    5454  CONTENT_CMD,
    5555  COUNT_CMD,
     56  DATETIME,
    5657  DBPRINT_CMD,
    5758  DEF_CMD,
  • kernel/timer.cc

    r5cb9ec rf9bb68  
    176176extern int iiOp;
    177177#endif
     178
     179char* dateTime()
     180{
     181#ifdef GETRUSAGE
     182  time_t rawtime;
     183  time(&rawtime);
     184  char* s = ctime(&rawtime);     // s: with linefeed at the end
     185  int l = strlen(s);
     186  char* ss = (char*)omAlloc(l);
     187  strncpy(ss, s, l - 1);
     188  ss[l - 1] = '\0';              // ss: without linefeed at the end
     189  return ss;
     190#else
     191  char* s = "Warning: date/time not available on your system";
     192  int l = strlen(s) + 1;
     193  char* ss = (char*)omAlloc(l);
     194  strncpy(ss, s, l - 1);
     195  ss[l - 1] = '\0';
     196  return ss;
     197#endif
     198}
     199
    178200void writeTime(const char* v)
    179201{
  • kernel/timer.h

    r5cb9ec rf9bb68  
    1212void startTimer(void);
    1313void writeTime(const char* s);
     14char* dateTime(); // (local) date and local time as a string
    1415
    1516int initTimer();
Note: See TracChangeset for help on using the changeset viewer.