Subversion Repositories SvarDOS

Rev

Rev 538 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 538 Rev 989
Line 1... Line 1...
1
/* This file is part of the SvarCOM project and is published under the terms
1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
2
 * of the MIT license.
3
 *
3
 *
4
 * Copyright (C) 2021 Mateusz Viste
4
 * Copyright (C) 2021-2022 Mateusz Viste
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Line 136... Line 136...
136
  unsigned short i;
136
  unsigned short i;
137
  unsigned short year = 0;
137
  unsigned short year = 0;
138
  unsigned char mo, dy;
138
  unsigned char mo, dy;
139
 
139
 
140
  if (cmd_ishlp(p)) {
140
  if (cmd_ishlp(p)) {
141
    outputnl("Displays or sets the system date.");
141
    nls_outputnl(32,0); /* "Displays or sets the system date."); */
142
    outputnl("");
142
    outputnl("");
143
    outputnl("DATE [date]");
143
    nls_outputnl(32,1); /* "DATE [date]" */
144
    outputnl("");
144
    outputnl("");
145
    outputnl("Type DATE with no parameters to display the current date and a prompt for a");
145
    nls_outputnl(32,2); /* "Type DATE with no parameters to display the (...)" */
146
    outputnl("new one. Press ENTER to keep the same date.");
-
 
147
    return(CMD_OK);
146
    return(CMD_OK);
148
  }
147
  }
149
 
148
 
150
  i = nls_getpatterns(nls);
149
  i = nls_getpatterns(nls);
151
  if (i != 0) {
150
  if (i != 0) {
Line 171... Line 170...
171
      pop cx
170
      pop cx
172
      pop ax
171
      pop ax
173
    }
172
    }
174
    buff[0] = ' ';
173
    buff[0] = ' ';
175
    nls_format_date(buff + 1, year, mo, dy, nls);
174
    nls_format_date(buff + 1, year, mo, dy, nls);
176
    output("Current date is");
175
    nls_output(32,4); /* "Current date is" */
177
    outputnl(buff);
176
    outputnl(buff);
178
    year = 0;
177
    year = 0;
179
  } else { /* parse date if provided */
178
  } else { /* parse date if provided */
180
    if ((cmd_date_parse(p->argv[0], &year, &mo, &dy, nls) != 0) || (cmd_date_set(year, mo, dy) != 0)) {
179
    if ((cmd_date_parse(p->argv[0], &year, &mo, &dy, nls) != 0) || (cmd_date_set(year, mo, dy) != 0)) {
181
      outputnl("Invalid date");
180
      nls_outputnl(32,3); /* "Invalid date" */
182
      year = 0;
181
      year = 0;
183
    }
182
    }
184
  }
183
  }
185
 
184
 
186
  /* ask for date if not provided or if input was malformed */
185
  /* ask for date if not provided or if input was malformed */
187
  while (year == 0) {
186
  while (year == 0) {
188
    output("Enter new date:");
187
    nls_output(32,5); /* "Enter new date:" */
189
    output(" ");
188
    output(" ");
190
    /* collect user input into buff */
189
    /* collect user input into buff */
191
    _asm {
190
    _asm {
192
      push ax
191
      push ax
193
      push bx
192
      push bx
Line 217... Line 216...
217
      pop bx
216
      pop bx
218
      pop ax
217
      pop ax
219
    }
218
    }
220
    if (buff[1] == 0) break; /* empty string = no date change */
219
    if (buff[1] == 0) break; /* empty string = no date change */
221
    if ((cmd_date_parse(buff + 2, &year, &mo, &dy, nls) == 0) && (cmd_date_set(year, mo, dy) == 0)) break;
220
    if ((cmd_date_parse(buff + 2, &year, &mo, &dy, nls) == 0) && (cmd_date_set(year, mo, dy) == 0)) break;
222
    outputnl("Invalid date");
221
    nls_outputnl(32,3); /* "Invalid date" */
223
  }
222
  }
224
 
223
 
225
  return(CMD_OK);
224
  return(CMD_OK);
226
}
225
}