Subversion Repositories SvarDOS

Rev

Rev 423 | Rev 430 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 423 Rev 426
Line 328... Line 328...
328
  }
328
  }
329
}
329
}
330
 
330
 
331
 
331
 
332
/* converts an ASCIIZ string into an unsigned short. returns 0 on success. */
332
/* converts an ASCIIZ string into an unsigned short. returns 0 on success. */
333
int atouns(unsigned short *r, const char *s) {
333
int atous(unsigned short *r, const char *s) {
334
  int err = 0;
334
  int err = 0;
335
 
335
 
336
  _asm {
336
  _asm {
337
    mov si, s
337
    mov si, s
338
    xor ax, ax  /* general purpose register */
338
    xor ax, ax  /* general purpose register */
Line 470... Line 470...
470
  /* compute the string */
470
  /* compute the string */
471
  return(sprintf(s, "%02u%s%02u%s%02u", items[0], p->datesep, items[1], p->datesep, items[2]));
471
  return(sprintf(s, "%02u%s%02u%s%02u", items[0], p->datesep, items[1], p->datesep, items[2]));
472
}
472
}
473
 
473
 
474
 
474
 
475
/* computes a formatted time based on NLS patterns found in p
475
/* computes a formatted time based on NLS patterns found in p, sc are ignored if set 0xff
476
 * returns length of result */
476
 * returns length of result */
477
unsigned short nls_format_time(char *s, unsigned char ho, unsigned char mn, const struct nls_patterns *p) {
477
unsigned short nls_format_time(char *s, unsigned char ho, unsigned char mn, unsigned char sc, const struct nls_patterns *p) {
478
  char ampm[2] = {0, 0};
478
  char ampm = 0;
479
  const char *fmt = "%02u%s%02u%s";
479
  unsigned short res;
-
 
480
 
480
  if (p->timefmt == 0) {
481
  if (p->timefmt == 0) {
481
    if (ho == 12) {
482
    if (ho == 12) {
482
      ampm[0] = 'p';
483
      ampm = 'p';
483
    } else if (ho > 12) {
484
    } else if (ho > 12) {
484
      ho -= 12;
485
      ho -= 12;
485
      ampm[0] = 'p';
486
      ampm = 'p';
486
    } else { /* ho < 12 */
487
    } else { /* ho < 12 */
487
      if (ho == 0) ho = 12;
488
      if (ho == 0) ho = 12;
488
      ampm[0] = 'a';
489
      ampm = 'a';
489
    }
490
    }
-
 
491
    res = sprintf(s, "%2u", ho);
-
 
492
  } else {
490
    fmt = "%2u%s%02u%s";
493
    res = sprintf(s, "%02u", ho);
491
  }
494
  }
-
 
495
 
-
 
496
  /* append separator and minutes */
492
  return(sprintf(s, fmt, ho, p->timesep, mn, ampm));
497
  res += sprintf(s + res, "%s%02u", p->timesep, mn);
-
 
498
 
-
 
499
  /* if seconds provided, append them, too */
-
 
500
  if (sc != 0xff) res += sprintf(s + res, "%s%02u", p->timesep, sc);
-
 
501
 
-
 
502
  /* finally append AM/PM char */
-
 
503
  if (ampm != 0) s[res++] = ampm;
-
 
504
  s[res] = 0;
-
 
505
 
-
 
506
  return(res);
493
}
507
}
494
 
508
 
495
 
509
 
496
/* computes a formatted integer number based on NLS patterns found in p
510
/* computes a formatted integer number based on NLS patterns found in p
497
 * returns length of result */
511
 * returns length of result */