Changeset 1074


Ignore:
Timestamp:
Jul 30, 2003, 11:23:28 PM (17 years ago)
Author:
luba
Message:
  • time and date in a locale-specific way
File:
1 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/library/Dos/time.cc

    r1013 r1074  
    88#include <time.h>
    99#include <sys/time.h>
     10#include <locale.h>
     11#include <langinfo.h>
    1012
    1113namespace refal
     
    1921RF_FUNC (Time, (), (RF_RES e_String))
    2022 
    21   static char* mname[] = {"Jan","Feb", "Mar", "Apr", "May", "Jun", "Jul",
    22                          "Aug", "Sep", "Oct", "Nov", "Dec"};
    23  
    2423  struct timeval ttt;
    2524  struct tm* lt;
    2625  unsigned uu;
     26
     27  setlocale(LC_TIME, "");
    2728
    2829  gettimeofday(&ttt,NULL);
     
    3031  uu = ttt.tv_usec/10000;
    3132
    32   e_String = ShortInt::create_expr((*lt).tm_mday) +
    33              Char::create_expr(" ") +
    34              Char::create_expr(mname[(*lt).tm_mon]) +
    35              Char::create_expr(" ") +
    36              ShortInt::create_expr((*lt).tm_year + 1900) +
    37              Char::create_expr(" ") +
    38              ShortInt::create_expr((*lt).tm_hour) +
    39              Char::create_expr(":") +
    40              ShortInt::create_expr((*lt).tm_min) +
    41              Char::create_expr(":") +
    42              ShortInt::create_expr((*lt).tm_sec) +
    43              Char::create_expr(".") +
    44              ShortInt::create_expr(uu);
     33  char s[256];
     34
     35  strftime(s, sizeof(s), nl_langinfo(D_T_FMT), lt);
     36 
     37  e_String = Char::create_expr(s) +
     38             Char::create_expr(".")+
     39             ShortInt::create_expr(uu) ;
     40
    4541RF_END
    4642
Note: See TracChangeset for help on using the changeset viewer.