Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  parse-day-of-week.js   Sprache: JAVA

 
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */


const expectedDate = new Date("1995-09-26T00:00:00");

// Each prefix will be tested with each format:
const prefixes = [
  "Tuesday, ",
  "Tuesday ",
  "Tuesday,",
  "Tuesday.",
  "Tuesday-",
  "Tuesday/",

  // Case insensitive
  "tuesday, ",
  "tUeSdAy ",

  // Abbreviations are valid down to the first character
  "Tuesda ",
  "Tue ",
  "T ",
  "t,",

  // Floating delimiters at beginning are allowed/ignored
  " ",
  ",",
  ", ",
  ".",
  "-",
  "/",

  // It doesn't actually need to be the correct day of the week, or
  // a day of week at all...you can put anything there
  "Monday ",
  "foo bar "
];
const formats = [
  "Sep 26 1995",
  "26 Sep 1995",
  "September 26, 1995",
  "26-Sep-1995",
  "1995-9-26",
  // ISO format is non-formal with day of week in front
  "1995-09-26",

  // You can put anything between the month and mday
  "Sep foo bar 26 1995",
  "Sep-foo bar-26 1995",
  "Sep-foo-bar-26 1995",

  // Redundant month names are allowed
  "Sep sep 26 1995",
  "Sep 26 sep 1995",
  // Edge case: if multiple month names, use the last one
  "Jan 26 1995 sep",
];

const rejected = [
  "Sep 26 foo 1995",
  "Sep 26 1995 foo",
  "1995 foo Sep 26",
  "foo2 Sep 26 1995",
  "Tuesday_Sep 26 1995",
  "foo_12",
];

for (const format of formats) {
  for (const prefix of prefixes) {
    const test = prefix + format;
    const testDate = new Date(test);

    assertEq(
      false, isNaN(testDate),
      `${test} should be accepted.`
    );

    assertEq(
      testDate.getTime(), expectedDate.getTime(),
      `"${test}" should be ${expectedDate} (got ${testDate}).`
    );
  }
}

for (const reject of rejected) {
  assertEq(
    true, isNaN(new Date(reject)),
    `"${reject}" should be rejected.`
  );
}

if (typeof reportCompare === "function")
  reportCompare(truetrue);

Messung V0.5
C=95 H=88 G=91

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge