Reply to comment

Vorsicht bei der Jahresangabe mit Zend_Date: yyyy vs. YYYY - ISO 8601

Heute nur ein kurzer Hinweis nach eigener Erfahrung:

Bei der Verwendung von Jahreswerten in Zend_Date muss immer genau überlegt werden, ob das Jahr laut ISO 8601 oder eine "normale" Jahresangabe verwendet werden soll.

Bei der Schreibweise über Konstanten ist der Unterschied zunächst nicht leicht zu erkennen
ISO8601 Schreibweise: YYYY
Jahr 4-Stellig (nicht ISO): yyyy

Soweit so unklar. Das fiese ist, dass man das Problem mit den ISO-Werten meist erst bemerkt, wenn man Grenzwerte, wie den Jahresanfang bestimmter Jahre testet. Gibt man so den 01.01.XXXX als ISO-Angabe ein, erhält man als ->toString('dd.MM.yyyy') oder ->get('dd.MM.yyyy') - Ausgabe des Zend_Date Objekt später nicht wieder das erwartete Datum, sondern einen Tag im vorausgehenden Jahr.

Das ist kein Bug!

Ich werde hier nicht genauer darauf eingehen, Interessierte können hier Details zum Iso Jahr nachlesen: http://en.wikipedia.org/wiki/ISO_week_date

Es sei aber darauf hingewiesen, dass ihr in den meisten Fällen, wenn ihr nicht gerade einen Kalender programmiert, NICHT die ISO-Schreibweise nutzen wollt.

So einen Fehler zu finden ist nicht leicht, daher hoffe ich euch geholfen zu haben, ihn gar nicht erst zu machen Wink

Einordnung:

Reply

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Internal paths in single or double quotes, written as "internal:node/99", for example, are replaced with the appropriate absolute URL or path. Paths to files in single or double quotes, written as "files:somefile.ext", for example, are replaced with the appropriate URL that can be used to download the file.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd><blockquote>
  • Lines and paragraphs break automatically.
  • Pairs of<blockquote> tags will be styled as a block that indicates a quotation.
  • You can enable syntax highlighting of source code with the following tags: <c>, <cpp>, <css>, <drupal5>, <drupal6>, <java>, <javascript>, <mysql>, <php>, <python>, <ruby>, <smarty>, <xml>. The supported tag styles are: <foo>, [foo]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.
  • Textual smileys will be replaced with graphical ones.
  • Each email address will be obfuscated in a human readable fashion or (if JavaScript is enabled) replaced with a spamproof clickable link.

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.