import { currentStoreView } from '@vue-storefront/core/lib/multistore'
import dayjs from 'dayjs'
import dayjsLocalizedFormat from 'dayjs/plugin/localizedFormat'
import { once } from '../helpers';

once('__VUE_EXTEND_DAYJS_LOCALIZED_FORMAT__', () => {
  dayjs.extend(dayjsLocalizedFormat)
})

/**
 * Converts date to format provided as an argument or defined in config file (if argument not provided)
 * @param {String} date
 * @param {String} format
 */
export function date (date, format) {
  const displayFormat = format || currentStoreView().i18n.dateFormat
  let storeLocale = currentStoreView().i18n.defaultLocale.toLocaleLowerCase()
  const separatorIndex = storeLocale.indexOf('-')
  const languageCode = separatorIndex ? storeLocale.substr(0, separatorIndex) : storeLocale

  const isStoreLocale = dayjs().locale(storeLocale).locale()
  const isLanguageLocale = dayjs().locale(languageCode).locale()
  const locale = isStoreLocale || isLanguageLocale

  if (locale) return dayjs(date).locale(languageCode).format(displayFormat)
  return dayjs(date).format(displayFormat)
}

@@ -705,16 +705,17 @@
 eCode = 
+(
 separato
@@ -720,16 +720,22 @@
 torIndex
+ %3E -1)
  ? store

Check separatorIndex is > -1 instead of truthiness