Permalink
Browse files

Merge pull request #973 from GlotPress/972-show-local-time

972: Add local time to editor meta
  • Loading branch information...
toolstack committed Jan 3, 2019
2 parents 0d9da67 + acaf266 commit 4132ed1260291d8d25cc9246869d9a80f9fb6320
Showing with 14 additions and 2 deletions.
  1. +8 −0 assets/js/editor.js
  2. +6 −2 gp-templates/translation-row-editor-meta.php
@@ -27,6 +27,12 @@ $gp.editor = (
show: function( element ) {
var row_id = element.closest( 'tr' ).attr( 'row' );
var editor = $( '#editor-' + row_id );
var gmt_date_added = $( '#gmt-date-added-' + row_id );
var local_date_added = $( '#local-date-added-' + row_id );
var offset = new Date().getTimezoneOffset();
var gmt_date = new Date( gmt_date_added.text() );
var local_date = new Date( ( gmt_date - ( offset * 60 * 1000 ) ) );

if ( ! editor.length ) {
return;
}
@@ -44,6 +50,8 @@ $gp.editor = (

$gp.editor.current = editor;

local_date_added.text( local_date.toLocaleDateString() + ' ' + local_date.toLocaleTimeString() );

editor.show();
editor.preview.hide();
$( 'tr:first', $gp.editor.table ).hide();
@@ -70,8 +70,12 @@
<?php endif; ?>
<?php if ( $translation->translation_added && '0000-00-00 00:00:00' !== $translation->translation_added ) : ?>
<dl>
<dt><?php _e( 'Date added:', 'glotpress' ); ?></dt>
<dd><?php echo esc_html( $translation->translation_added ); ?> GMT</dd>
<dt><?php _e( 'Date added (GMT):', 'glotpress' ); ?></dt>
<dd id="gmt-date-added-<?php echo esc_attr( $translation->row_id ); ?>"><?php echo esc_html( $translation->translation_added ); ?></dd>
</dl>
<dl>
<dt><?php _e( 'Date added (local):', 'glotpress' ); ?></dt>
<dd id="local-date-added-<?php echo esc_attr( $translation->row_id ); ?>"><?php _e( 'Calculating...', 'glotpress' ); ?></dd>
</dl>
<?php endif; ?>
<?php if ( $translation->user ) : ?>

0 comments on commit 4132ed1

Please sign in to comment.