Skip to content

Commit

Permalink
changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
dzonidoo committed Aug 5, 2024
1 parent 80d83dc commit ab5721c
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
4 changes: 2 additions & 2 deletions scripts/appConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ if (appConfig.shortTimeFormat == null) {
}

if (appConfig.view.dateformat == null) {
appConfig.view.dateformat = 'MM/DD'; // 24h format
appConfig.view.dateformat = 'MM/DD';
}

if (appConfig.view.timeformat == null) {
appConfig.view.timeformat = 'hh:mm'; // 24h format
appConfig.view.timeformat = 'hh:mm';
}

if (appConfig.longDateFormat == null) {
Expand Down
5 changes: 3 additions & 2 deletions scripts/apps/archive/services/ArchiveService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _ from 'lodash';
import moment from 'moment';
import {formatDate} from 'core/get-superdesk-api-implementation';
import {appConfig} from 'appConfig';

ArchiveService.$inject = ['desks', 'session', 'api', '$q', 'search', '$location'];
export function ArchiveService(desks, session, api, $q, search, $location) {
Expand Down Expand Up @@ -81,7 +81,8 @@ export function ArchiveService(desks, session, api, $q, search, $location) {
* @return {Object} the list of archive items
*/
this.getRelatedItems = function(item, fromDateTime) {
var beforeDateTime = formatDate(fromDateTime || moment().subtract(1, 'days'));
var beforeDateTime = fromDateTime || moment().subtract(1, 'days')
.format(appConfig.view.dateformat);
var params: any = {};

params.q = 'slugline.phrase:"' + _.trim(item.slugline) + '"'; // exact match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {translateArticleType, gettext} from 'core/utils';
import {IArticle} from 'superdesk-api';
import {slideUpDown} from 'core/ui/slide-up-down';
import {runBeforeUpdateMiddlware} from '../services/authoring-helpers';
import {formatDate} from 'core/get-superdesk-api-implementation';

AuthoringHeaderDirective.$inject = [
'api',
Expand Down Expand Up @@ -195,7 +194,8 @@ export function AuthoringHeaderDirective(
scope.missing_link = false;
if (scope.item.slugline && scope.item.type === 'text') {
// get the midnight based on the default timezone not the user timezone.
var fromDateTime = formatDate(moment());
var fromDateTime = moment().tz(appConfig.default_timezone)
.format(appConfig.view.dateformat);

archiveService.getRelatedItems(scope.item, fromDateTime)
.then((items) => {
Expand Down
4 changes: 2 additions & 2 deletions scripts/apps/search/components/fields/embargo.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import moment from 'moment';
import {gettext} from 'core/utils';
import {longFormat} from 'core/datetime/datetime';
import {IPropsItemListInfo} from '../ListItemInfo';
import {formatDate} from 'core/get-superdesk-api-implementation';

class EmbargoComponent extends React.PureComponent<IPropsItemListInfo> {
render() {
Expand All @@ -23,7 +23,7 @@ class EmbargoComponent extends React.PureComponent<IPropsItemListInfo> {
key="embargo"
className="state-label state_embargo"
title={embargoed != null ? (
gettext('Embargo until {{date}}', {date: longFormat(embargoed)})
gettext('Embargo until {{date}}', {date: formatDate(embargoed, {longFormat: true})})
) : (
gettext('Embargo: {{text}}', {text: embargoedText})
)}
Expand Down
5 changes: 2 additions & 3 deletions scripts/apps/search/components/fields/state.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react';
import {gettext} from 'core/utils';
import {IPropsItemListInfo} from '../ListItemInfo';
import {longFormat} from 'core/datetime/datetime';
import {assertNever} from 'core/helpers/typescript-helpers';
import {ITEM_STATE} from 'apps/search/interfaces';
import {openArticle} from 'core/get-superdesk-api-implementation';
import {formatDate, openArticle} from 'core/get-superdesk-api-implementation';

export function getStateLabel(itemState: ITEM_STATE) {
switch (itemState) {
Expand Down Expand Up @@ -43,7 +42,7 @@ export class StateComponent extends React.Component<Pick<IPropsItemListInfo, 'it
const scheduled = props.item.archive_item?.schedule_settings?.utc_publish_schedule;

if (scheduled != null) {
title = gettext('Scheduled for {{date}}', {date: longFormat(scheduled)});
title = gettext('Scheduled for {{date}}', {date: formatDate(scheduled, {longFormat: true})});
}
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/apps/search/components/fields/used.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React from 'react';
import {gettext} from 'core/utils';
import {longFormat} from 'core/datetime/datetime';
import {IPropsItemListInfo} from '../ListItemInfo';
import {formatDate} from 'core/get-superdesk-api-implementation';

export class Used extends React.PureComponent<IPropsItemListInfo> {
label: boolean = false;
render() {
const item = this.props.item;

if (item.used) {
const title = item.used_updated ? longFormat(item.used_updated) : null;
const title = item.used_updated ? formatDate(item.used_updated, {longFormat: true}) : null;

return (
<div className="label label--red2" key="used" title={title}>
Expand Down
5 changes: 1 addition & 4 deletions scripts/core/datetime/datetime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const SERVER_FORMAT = 'YYYY-MM-DDTHH:mm:ssZZ';
*
* @param {String} d iso format datetime
*/
export function longFormat(d: string | moment.Moment): string {
return moment(d).format(LONG_FORMAT);
}

export function serverFormat(d: string | moment.Moment): string {
return moment(d).utc().format(SERVER_FORMAT);
Expand Down Expand Up @@ -165,7 +162,7 @@ function DateTimeService() {
return m.format(DATE_FORMAT);
};

this.longFormat = longFormat;
this.longFormat = (date) => formatDate(date, {longFormat: true});
}

DateTimeHelperService.$inject = [];
Expand Down

0 comments on commit ab5721c

Please sign in to comment.