Beispiel #1
0
int ui_timer_update()
{
	static Timespec last = { 0 };
	Timespec current = { 0 };
	uchar timeOut[] = "DD:HH:MM:SS:MS";
	uint length = 0;
	int status = 0;

	status = time_convert( &current );
	ASSERT( status == ERR_NONE );

#define UI_TIMER_ASSIGN( field, index )		\
	do {					\
		length = utos( current.field, (char*)(timeOut + 3 * index) ); \
		if( length == 1 ){					\
			timeOut[ 3 * index + 1 ] = timeOut[ 3 * index ]; \
			timeOut[ 3 * index ] = '0';			\
		}							\
		timeOut[ 3 * index + 2 ] = ':';				\
	} while( 0 )

	last = current;
	UI_TIMER_ASSIGN( day, 0 );
	UI_TIMER_ASSIGN( hour, 1 );
	UI_TIMER_ASSIGN( min, 2 );
	UI_TIMER_ASSIGN( sec, 3 );
	UI_TIMER_ASSIGN( msec, 4 );
	timeOut[ 14 ] = '\0';

	region_write( cons, ( char* )timeOut );
	region_flush( cons );
	
	return ERR_NONE;
}
int main(){
    // char* time = (char *)malloc(10240 * sizeof(char));
    // scanf("%s",time);

    int i;


    char testCases[NUMTESTCASES][100] = {
      "00:00:00AM",
      "00:00:00PM",
      "12:00:00AM",//00:00:00
      "12:00:00PM",//12:00:00
      "03:00:00AM",
      "03:00:00PM",
      "07:05:45AM",
      "07:05:45PM",
      "07:15:00PM",
      "07:05:12PM",
      "11:05:56PM",
      "11:45:00PM",
    };

    for(i=0;i<NUMTESTCASES;i++){
        time_convert(testCases[i]);
    }


    return 0;
}
Beispiel #3
0
static PyObject *
time_localtime(PyObject *self, PyObject *args)
{
	double when;
	if (!parse_time_double_args(args, "|O:localtime", &when))
		return NULL;
	return time_convert(when, localtime);
}
Beispiel #4
0
static PyObject *
time_localtime(PyObject *self, PyObject *args)
{
	double when;
	if (PyTuple_Size(args) == 0)
		when = floattime();
	if (!PyArg_ParseTuple(args, "|d:localtime", &when))
		return NULL;
	return time_convert((time_t)when, localtime);
}
Beispiel #5
0
main()
{
  register long k;
  unsigned char t, incode[2], ans[2], yn[2], again[2];
  unsigned char timestr[30], datetime[15], intime[20];
  long systime;
  long pid, status;

  putenv("_=transac_output");
  chdir(getenv("HOME"));

  open_all();

  fix(transac_output);
  sd_screen_off();
  sd_clear_screen();
  sd_text(transac_output);
  sd_screen_on();
  
  sd_prompt(&fld[0], 0);

  while(1)
  {
    for (k = 15; k <= 20; k++)
    {
      sd_cursor(0, k, 1);
      sd_clear_line();
    }
    while(1)
    {
      memset(incode, 0, 2);

      t = sd_input(&fld[0], 0, 0, incode, 0);
      if(t == EXIT)      leave();
      if(t == UP_CURSOR) continue;

      if (!*incode) break;

      *incode = tolower(*incode);
        
      if (*incode != 'c' && *incode != 'd' &&
          *incode != 'p' && *incode != 'e')
      {
        eh_post(ERR_CODE, incode);
        continue;
      }
      break;
    }
    if (*incode == 'p')
    {
      if (sp->sp_to_flag != 'y' && sp->sp_to_flag != 'b')
      {
        eh_post(LOCAL_MSG, "No Transaction File Feature");
        continue;
      }
      sd_wait();
      
      if((pid = fork()) == 0)
      {
        ss_close();
        execlp("transac_short_rpt", "transac_short_rpt", 0);
        exit(1);
      }
      else pid = wait(&status);

      if (pid > 0 && !status) eh_post(ERR_CONFIRM, "Short Printing");
      else eh_post(CRASH_MSG, "tranac_short_rpt failed");
      continue;
    }
    if (*incode == 'e')
    {
      if (sp->sp_to_flag != 'y' && sp->sp_to_flag != 'b')
      {
        eh_post(LOCAL_MSG, "No Transaction File Feature");
        continue;
      }
      while(1)
      {
        memset(ans, 0, 2);                /* are you sure response           */
        memset(yn, 0, 2);
        
        t = sd_input(&fld[5],sd_prompt(&fld[5],0), 0, yn, 0);
        if (t == EXIT)      leave();
        if (t == UP_CURSOR) break;

        *ans = code_to_caps(*yn);

        if(*ans != 'y' && *ans != 'n')
        {
          eh_post(ERR_YN,0);
          continue;
        }
        if(*ans == 'y')
        {
          eh_post(LOCAL_MSG, "Purging Transaction File");

          database_open();
          xt_open();
          transaction_setkey(0);
          
          begin_work();
          while (!transaction_next(&xt, LOCK)) 
          {
            transaction_delete();
            commit_work();
            begin_work();
          }
          commit_work();
          xt_close();
          database_close();
          
          sp->sp_to_count = 0;
          
          eh_post(PURGE_TRANS, 0);
        }
        break;
      }                                   /* end while(1)                    */
      continue;
    }                                     /* end if                          */
    if (*incode == 'c' || *incode == 'd')
    {
      if (sp->sp_to_mode != 0x20 || sp->sp_oi_mode == *incode) /* F071395    */
      {
        eh_post(LOCAL_MSG, "Device/Port In Use");          
        continue;
      }
    }
    if (*incode == 'd')
    {
      while(1)
      {
        memset(ans, 0, 2);
        memset(yn, 0, 2);
        
        t = sd_input(&fld[1],sd_prompt(&fld[1],0), 0, yn, 0);
        if (t == EXIT)     leave();
        if (t == UP_CURSOR) break;

        *ans = code_to_caps(*yn);
        
        if(*ans != 'y' && *ans != 'n')
        {
          eh_post(ERR_YN,0);
          continue;
        }
        break;
      }
      if (t == UP_CURSOR) continue;
      if (*ans == 'n') continue;          /* abort diskette in               */
    }
    while(1)
    {
      memset(again, 0, 2);                /* retransmit response             */
      memset(yn, 0, 2);
      
      t = sd_input(&fld[2],sd_prompt(&fld[2],0), 0, yn, 0);
      if (t == EXIT)     leave();
      if (t == UP_CURSOR) break;

      *again = code_to_caps(*yn);
      if (*again != 'y' && *again != 'n')
      {
        eh_post(ERR_YN, 0);
        continue;
      }
      break;
    }
    if (t == UP_CURSOR) continue;

    while(1)
    {
      memset(ans, 0, 2);                  /* purge response                  */
      memset(yn, 0, 2);
      
      t = sd_input(&fld[3],sd_prompt(&fld[3],0), 0, yn, 0);
      if(t == EXIT)      leave();
      if(t == UP_CURSOR) break;

      *ans = code_to_caps(*yn);
      if(*ans != 'y' && *ans != 'n')
      {
        eh_post(ERR_YN,0);
        continue;
      }
      break;
    }
    if(*ans == 'y')
    {
      sd_prompt(&fld[4],0);
      systime = time(0) - sp->sp_purge_window;
      strcpy(timestr, ctime(&systime));
      timestr[24] = 0;
      sd_cursor(0,18,25);
      sd_text("Default Date/Time:");
      sd_cursor(0,18,54);
      sd_text(&timestr[4]);
      sd_cursor(0,20,25);
      sd_text("Format is:");
      sd_cursor(0,20,54);
      sd_text("mm/dd/yyyy hh:mm:ss");

      while(1)
      {
        t = sd_input(&fld[4], 0, 0, intime, 0);
        if(t == EXIT)      leave();
        if(t == UP_CURSOR) break;

        if(*intime != 0)
        {
          if(!time_convert(intime, &systime))
          {
            eh_post(ERR_TIME, intime);
            continue;
          }
        }
        eh_post(LOCAL_MSG, "Purging Orders");

        if ((pid = fork()) == 0)
        {
          sprintf(datetime, "%d", systime);
          ss_close();
          execlp("order_purge", "order_purge", datetime, 0);
          exit(1);
        }
        else pid = wait(&status);

        if (pid > 0 && !status) eh_post(ERR_CONFIRM, "Order purge");
        else eh_post(CRASH_MSG, "order_purge failed");
        break;
      }
      if (t == UP_CURSOR) continue;
    }
    if (*again == 'n')                    /* transmit current file           */
    {
      eh_post(LOCAL_MSG, "Extracting Transactions");

      if ((pid = fork()) == 0)
      {
        ss_close();
        execlp("transac_copy", "transac_copy", 0);
        exit(1);
      }
      else pid = wait(&status);

      if (pid < 0 || status)
      {
        eh_post(LOCAL_MSG, "transac_copy failed");
        continue;
      }
      eh_post(ERR_CONFIRM, "Transaction File");
    }
/*
 *  Start Transaction Output Operations
 */
    if (*incode == 'c')                   /* comm output                     */
    {
      if (sp->sp_commo_trans_out == 'n')
      {
        eh_post(LOCAL_MSG, "No Communication Feature");
        continue;
      }
      eh_post(LOCAL_MSG, "Sending Transactions");
      sd_close();

      sp->sp_to_mode = 'c';
      
      if (fork() == 0)
      {
        if (sp->sp_commo_trans_out == 'k') 
        {
          ss_close();
          execlp("com_kermit_out", "com_kermit_out", 0);
        }
        else 
        {
          ss_close();
          execlp("comsend",  "comsend",  0);
        }
        ss_open();
        sd_open();
        sp->sp_to_mode = 0x20;
        eh_post(LOCAL_MSG, "Program Not Found");
        continue;
      }
      pid = wait(&status);
      sp->sp_to_mode = 0x20;
      sd_open();
      
      if (pid < 0 || status) 
      {
        eh_post(LOCAL_MSG, "Communications Failed");
      }
      else eh_post(ERR_CONFIRM, "Transactions Output");
      continue;
    }
    if (*incode == 'd')
    {
      sd_wait();

      sp->sp_to_mode = 'd';

      sprintf(message, command);
      status = system(message);
      sp->sp_to_mode = 0x20;
      
      if (status) eh_post(LOCAL_MSG, "Diskette output failed");
      else eh_post(ERR_CONFIRM, "Tranaction Output");
    }
  }
}