Uploaded image for project: 'In-Portal CMS'
  1. In-Portal CMS
  2. INP-378

Create new Tag to display language-specific Date parts

    XMLWordPrintable

    Details

    • Type: Feature Request
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 5.0.1
    • Fix Version/s: 5.1.0-B1
    • Component/s: Data Management
    • Labels:
      None
    • Additional information:
      Hide

      [B]Proposed solution, that needs to be adapted into new tag in kDBTagProcessor:[/B]

      /**

      • Returns formatted date + time on current language
      • @param string $format
      • @param int $timestamp
      • @param string $case_suffixes
      • @return string
        */
        function LanguageDate($format, $timestamp = false, $case_suffixes =
        '')
        {
        if (!$timestamp) $timestamp = adodb_mktime();
        // apply timezone adjustment manually (because we are not using
        kDateFormatter)
        $date = $timestamp + $this->Application->TimeZoneAdjustment();

      $replacements = Array (
      'l' => 'la_WeekDay',
      'D' => 'la_WeekDay',
      'M' => 'la_Month',
      'F' => 'la_Month',
      );

      if ($case_suffixes) {
      // apply case suffixes (for russian language only)
      $case_suffixes = explode(',', $case_suffixes);

      foreach ($case_suffixes as $case_suffux)

      { list ($replacement_name, $case_suffix_value) = explode('=', $case_suffux, 2); $replacements[$replacement_name] .= $case_suffix_value; }


      }

      foreach ($replacements as $format_char => $phrase_prefix) {
      if (strpos($format, $format_char) === false)

      { unset($replacements[$format_char]); continue; }

      $replacements[$format_char] =
      $this->Application->Phrase($phrase_prefix . adodb_date($format_char,
      $date));
      $format = str_replace($format_char, '#' . ord($format_char)
      . '#', $format);
      }

      $date_formatted = adodb_date($format, $date);

      foreach ($replacements as $format_char => $format_replacement)

      { $date_formatted = str_replace('#' . ord($format_char) . '#', $format_replacement, $date_formatted); }

      return $date_formatted;
      }

      Show
      [B] Proposed solution, that needs to be adapted into new tag in kDBTagProcessor: [/B] /** Returns formatted date + time on current language @param string $format @param int $timestamp @param string $case_suffixes @return string */ function LanguageDate($format, $timestamp = false, $case_suffixes = '') { if (!$timestamp) $timestamp = adodb_mktime(); // apply timezone adjustment manually (because we are not using kDateFormatter) $date = $timestamp + $this->Application->TimeZoneAdjustment(); $replacements = Array ( 'l' => 'la_WeekDay', 'D' => 'la_WeekDay', 'M' => 'la_Month', 'F' => 'la_Month', ); if ($case_suffixes) { // apply case suffixes (for russian language only) $case_suffixes = explode(',', $case_suffixes); foreach ($case_suffixes as $case_suffux) { list ($replacement_name, $case_suffix_value) = explode('=', $case_suffux, 2); $replacements[$replacement_name] .= $case_suffix_value; } } foreach ($replacements as $format_char => $phrase_prefix) { if (strpos($format, $format_char) === false) { unset($replacements[$format_char]); continue; } $replacements [$format_char] = $this->Application->Phrase($phrase_prefix . adodb_date($format_char, $date)); $format = str_replace($format_char, '#' . ord($format_char) . '#', $format); } $date_formatted = adodb_date($format, $date); foreach ($replacements as $format_char => $format_replacement) { $date_formatted = str_replace('#' . ord($format_char) . '#', $format_replacement, $date_formatted); } return $date_formatted; }
    • External issue ID:
      453
    • Copy Issue Key:
    • Patch Instructions:

      Patches must be submitted through Phabricator.

      Description

      I propose to create tag for displaying language-specific date parts, like weekday, month name etc. on site language, not always on english as date function of php offers.

      Code is supposed to be new tag in kDBTagProcessor like Field tag is. Only difference is that it will display formatted date field contents. Optional parameter "value" will allow to format any abstract date as well (not from database). Code, I've attached is helper method, that was called from LanguageDate tag.

      Tag CurrentDate in LanguageTagProcessor is not related to this discussion in any way.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                alex Alex
                Reporter:
                dmitry Dmitry Andrejev [Intechnic]
                Developer:
                Alex
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: