Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  datetime_utils.js

  Sprache: JAVA
 

// Format datetime <input> value in the same way as we do for
// the overflow/underflow/step mismatch validation messages.
function formatDateTimeForValidityMessage(value, inputType) {
  let date;
  if (inputType === "week") {
    let parts = value.split("-W");
    console.assert(parts.length === 2"invalid week value: " + value);
    let year = parts[0];
    let weekNumber = parseInt(parts[1]);
    let jan1 = new Date(year + "-01-01T00:00:00");
    // the day of January corresponding to year-W1-Thursday
    let dayOfW1 = ((11 - jan1.getDay()) % 7) + 1;
    // Date corresponding to year-W1-Thursday
    let w1Day1 = new Date(`${year}-01-0${dayOfW1}T00:00:00`);
    // we use the Monday of the week for the validity message
    let dayOffset = -3;
    let dayOfYear = 7 * (weekNumber - 1) + dayOffset;
    date = new Date(w1Day1.getTime() + 1000 * 60 * 60 * 24 * dayOfYear);
  } else if (inputType === "time") {
    // add arbitrary day so Date constructor is happy
    date = new Date("2000-01-01T" + value);
  } else if (inputType === "date") {
    // add arbitrary time so Date constructor uses local time instead of UTC
    date = new Date(value + "T00:00:00");
  } else if (inputType === "month") {
    date = new Date(value + "-01T00:00:00");
  } else {
    date = new Date(value);
  }
  let timeOptions = {
    hour: "2-digit",
    minute: "2-digit",
  };
  if (date.getSeconds()) {
    timeOptions.second = "2-digit";
  }
  if (date.getMilliseconds()) {
    timeOptions.second = "2-digit";
    timeOptions.fractionalSecondDigits = 3;
  }
  let options = {
    "datetime-local": {
      year: "numeric",
      month: "2-digit",
      day: "2-digit",
      ...timeOptions,
    },
    month: {
      year: "numeric",
      month: "2-digit",
    },
    date: {
      year: "numeric",
      month: "2-digit",
      day: "2-digit",
    },
    time: timeOptions,
  };
  options.week = options.date;
  console.assert(
    options[inputType],
    "Invalid datetime input type: " + inputType
  );
  return date.toLocaleString(undefined, options[inputType]);
}

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=476070
#Domains=661743