Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payment date details #687

Closed
Rahe opened this issue Jul 4, 2016 · 7 comments
Closed

Payment date details #687

Rahe opened this issue Jul 4, 2016 · 7 comments
Assignees
Milestone

Comments

@Rahe
Copy link
Contributor

Rahe commented Jul 4, 2016

Hello,

In the payment admin page there is a metabox for the payment metadate like the date, the status and such.
But the date displayed is at the format m/d/Y wich in french can be very disturbing because '06/30/2016' is not a valid date in France, for us this will be '30/06/2016'.

Can you consider using https://jqueryui.com/datepicker/#alt-field with a filter for the displayed date ? So you can keep the mm/dd/YY format and display the user friendly localized date ?

@DevinWalker
Copy link
Member

Hey @Rahe I was just thinking about how we need to standardize the date format throughout the plugin. What the best was to do that for all the various date formats is that we use the WordPress default date setting found under WP-Admin > Settings > General:

screen shot 2016-07-04 at 4 38 14 pm

@DevinWalker DevinWalker self-assigned this Jul 4, 2016
@Rahe
Copy link
Contributor Author

Rahe commented Jul 5, 2016

Hi @DevinWalker,

this was my first idea too, but this setting is for dispalying a date on the frontend and it's not really usefull to have a "Wednesdays, 2 april" displayed at this place, this is most usefull to have a "normal" date format at this place but i18n.

I think a setting into the plugin like a "display date format" not bound to the save format. I have seen the date used is the WordPress post_date field, so this is easy to format it into an another format.

Rahe

@ramiy
Copy link
Contributor

ramiy commented Jul 18, 2016

@DevinWalker, date formats is a known issue.

Only the US and it's uses the mm/dd/yy format. Most of the world (including Europe) uses dd/mm/yy. For more info see this link: https://en.wikipedia.org/wiki/Date_format_by_country

Last year WordPress core changed the way they handle dates in the admin.

In the past core used the get_option('date_format') function. But it was changed in favor of local translation strings. See this changeset: https://core.trac.wordpress.org/changeset/35811

Now, each language can use https://translate.wordpress.org/ to set it's preferred date format. Much simpler solution.

I guess adding a filter will be a good idea.

@DevinWalker
Copy link
Member

How about a function like give_date_format() that passes get_option('date_format') through a filter called give_date_format like Woo's:

screen_shot_2016-07-19_at_10 09 09_pm

The confusing thing though is the various date formats found throughout Woo. For example, here is the frontend checkout page which respects my date option in WP-admin:

screen shot 2016-07-19 at 9 55 29 am

screen shot 2016-07-19 at 9 56 56 am

And here in wp-admin on Woo's transaction edit screen and on the reports page the date is yyyy-mm-dd:

screen shot 2016-07-19 at 9 55 48 am

screen shot 2016-07-19 at 9 55 18 am

Where it appears hardcoded as this format: <?php echo date_i18n( 'Y-m-d', strtotime( $post->post_date ) ); ?>: https://github.com/woothemes/woocommerce/blob/master/includes/admin/meta-boxes/class-wc-meta-box-order-data.php#L200

What went into this decision by the Woo team and should we follow suit? I'm guessing that the Y-m-d is the most internationally recognized format.

@DevinWalker DevinWalker removed their assignment Jul 20, 2016
@DevinWalker
Copy link
Member

@ravinderk please paste your give_get_date function here when you get a chance! 😄

@DevinWalker DevinWalker added this to the 1.7 milestone Jul 20, 2016
@ravinderk
Copy link
Collaborator

@DevinWalker Here is function which I proposed.

/**
 * Get date format string on basis of given context
 * @param  string $date_context    Date format context name.
 * @return string                  Date format string
 */
function give_date_format ( $date_context='') {
      // Date format context.
      // You can add your context or use already exist context.
      $date_format_contexts = apply_filter(
        'give_date_format_contexts'
        array(
          'checkout' => 'F j, Y',
          'report'   => 'Y-m-d',
          'email'    => 'm/d/Y',
        )
      );

      // Set date format to default date format.
      $date_format = get_option('date_Format');


      // Update date format if we have non empty date format context and non empty date format string for that context.
      if( $date_context && array_key_exists( $date_format_context, $date_format_contexts ) ) {
        $date_format = ! empty( $date_format_contexts[ $date_context ] )
          ? $date_format_contexts[ $date_context ]
          : $date_format;
      }
​      
      // Result.
      return apply_filters( 'give_date_format', $date_format );
   }

@DevinWalker
Copy link
Member

Thanks @ravinderk

DevinWalker pushed a commit that referenced this issue Aug 26, 2016
DevinWalker pushed a commit that referenced this issue Aug 29, 2016
* release/1.7: (177 commits)
  Added change log for #964
  Make exception message translatable
  Update give_do_automatic_upgrades function
  Move upgades to 1.7
  Update function version from 1.6 to 1.7
  add missing `echo` after 9a2f35d
  Set gulp textdomain task autocorretion to true
  Update more action names #957
  Update actions to use newly termed ones rather than now deprecated ones #957
  Version bump for release/1.7 branch
  Change log added for #687
  Readme logs added for #896 and #773
  replace `edd` text-domain with `give`
  replace esc_attr_e() with esc_attr()
  add misisng text-domain
  gulp task
  Update doc block in formatting.php
  Refresh current month transient when payment update
  Add function to get stat transient key
  Update description in Give Settings Screen
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants