Skip to content

w2p_Utilities_Date::format() ignores %: literal letters are replaced and most codes are unsupported #519

Closed

Description

@caseysoftware

w2p_Utilities_Date::format() (classes/w2p/Utilities/Date.class.php) splits the format string into single characters and replaces each one it recognises, ignoring %:

$_config = str_split($format);
foreach ($_config as $value) {
    switch ($value) {
        case 'Y': case 'd': case 'm': case 'H': ...

So:

  • Literal letters are replaced. Any Y, d, m, H, I, S, M, p, b, B, A, T or U in a format string becomes a date part, whether or not it follows %.
  • Unsupported codes come out as the bare letter. %w, %a, %e, %y, %j, %D and the other strftime/PEAR codes the class used to inherit are not handled.

For 2026-10-21 14:05:09 (a Wednesday):

Format Output
%w w
%a a
%e / %y / %j / %D e / y / j / D
%d de %B de %Y 21 21e October 21e 2026
Today: %A 14:05:09o21ay: Wednesday

Effects found so far:

  • w2p_Output_MonthCalendar compared cells with format('%Y%m%d%w'), so today was never highlighted (worked around locally by comparing %Y%m%d).
  • getBeginWeek() / getEndWeek() use Format('%w'); see the separate issue.
  • Any user date/time format preference (SHDATEFORMAT, TIMEFORMAT) that contains other codes or literal text is mangled.

Fix: parse %x pairs (copy anything else through unchanged), and support the codes the code base and the date-format preferences use. A test per supported code, plus literal text, would pin it down. Worth auditing the stored SHDATEFORMAT/TIMEFORMAT choices and every format()/Format() call for codes that aren't supported today.

Activity

  1. added
    php
    on Oct 23, 2026
  2. added 2 commits that reference this issue on Oct 24, 2026
    5d56a2a
    ad5fed9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    php

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions