Ignore:
Timestamp:
Jul 5, 2020, 9:26:49 PM (4 years ago)
Author:
coas-nagasima
Message:

dateコマンド追加
コードの整理

File:
1 edited

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/ntshell/ntshell/usrcmd.c

    r424 r433  
    789789}
    790790
     791int usrcmd_date(int argc, char **argv)
     792{
     793        int ret;
     794        struct timespec tp;
     795        char buf[30];
     796
     797        ret = shell_clock_gettime(CLOCK_REALTIME, &tp);
     798        if (ret != 0) {
     799                ntstdio_printf(&ntstdio, "clock_gettime error %d", ret);
     800                return 0;
     801        }
     802
     803        memset(buf, 0, sizeof(buf));
     804        if (ctime_r(&tp.tv_sec, buf) == NULL) {
     805                ntstdio_printf(&ntstdio, "ctime_r error");
     806                return 0;
     807        }
     808
     809        /* 改行コードの削除 */
     810        ret = ntlibc_strlen(buf);
     811        buf[ret - 1] = '\0';
     812
     813        ntstdio_printf(&ntstdio, "%s .%09ld\n", buf, tp.tv_nsec);
     814        return 0;
     815}
     816
    791817int usrcmd_info(int argc, char **argv)
    792818{
Note: See TracChangeset for help on using the changeset viewer.