Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
schoolHomeFeatureEligibilityPresenter.getPresentationData = (checkWindowData, timezone) => {
const currentDate = moment.tz(timezone || config.DEFAULT_TIMEZONE)
const featureEligibilityData = {}
const resultsPublishedDate = checkWindowData.checkEndDate.clone()
.add(1, 'weeks').isoWeekday('Monday')
.utcOffset(currentDate.utcOffset(), true)
.set({ hour: 6, minutes: 0, seconds: 0 })
// Pin generation
featureEligibilityData.familiarisationCheckStartDate = dateService.formatFullGdsDate(checkWindowData.familiarisationCheckStartDate)
featureEligibilityData.familiarisationCheckEndDate = dateService.formatFullGdsDate(checkWindowData.familiarisationCheckEndDate)
featureEligibilityData.liveCheckStartDate = dateService.formatFullGdsDate(checkWindowData.checkStartDate)
featureEligibilityData.liveCheckEndDate = dateService.formatFullGdsDate(checkWindowData.checkEndDate)
// Results
featureEligibilityData.resultsPublishedDate = dateService.formatFullGdsDate(resultsPublishedDate)
// TODO: logic related properties should get refactored into services
_calculateStartMoment(props) {
let start;
// NOTE: Since we initialize a new time from one of the properties of
// the props.currentMomet, we need to check for the timezone!
//
// Other relative operations (like adding or subtracting time) are
// independent of a timezone.
const tz = props.currentMoment.tz();
if (tz) {
start = moment.tz([props.currentMoment.year()], tz);
} else {
start = moment([props.currentMoment.year()]);
}
start = start
.weekday(0)
.week(props.currentMoment.week())
.subtract(BUFFER_DAYS, 'days');
return start;
}
_calculateStartMoment(props) {
let start;
// NOTE: Since we initialize a new time from one of the properties of
// the props.currentMomet, we need to check for the timezone!
//
// Other relative operations (like adding or subtracting time) are
// independent of a timezone.
const tz = props.currentMoment.tz()
if (tz) {
start = moment.tz([props.currentMoment.year()], tz)
} else {
start = moment([props.currentMoment.year()])
}
start = start.weekday(0).week(props.currentMoment.week())
.subtract(BUFFER_DAYS, 'days')
return start
}
it('works with a date having a specified timezone and a given timezone', function() {
expect(new Time(momentTimezone.tz('2017-05-31 12:45:00', 'Asia/Dubai'), '-08:00')).to.be.deep.equal({
utc: '2017-05-31T08:45:00.000Z',
timestamp: 1496220300,
day_of_week: 2,
day_of_month: 31,
month_of_year: 5,
time_of_day: 0.75,
timezone: '-08:00'
});
});
});
export function formatTime(stamp: Time) {
if (stamp.sec < 0 || stamp.nsec < 0) {
console.error("Times are not allowed to be negative");
return "(invalid negative time)";
}
return moment.tz(toDate(stamp), moment.tz.guess()).format("h:mm:ss.SSS A z");
}
businessAvailabilityService.getAvailabilityData = async (schoolId, checkWindowData, timezone) => {
const currentDate = moment.tz(timezone || config.DEFAULT_TIMEZONE)
const isWithinOpeningHours = currentDate.hour() >= 8 && currentDate.hour() < 16
const hdfSubmitted = await headteacherDeclarationService.isHdfSubmittedForCheck(schoolId, checkWindowData.id)
const familiarisationWindowStarted = currentDate.isAfter(checkWindowData.familiarisationCheckStartDate)
const familiarisationWindowClosed = currentDate.isAfter(checkWindowData.familiarisationCheckEndDate)
const checkWindowStarted = currentDate.isAfter(checkWindowData.checkStartDate)
const checkWindowClosed = currentDate.isAfter(checkWindowData.checkEndDate)
const checkWindowYear = dateService.formatYear(checkWindowData.checkEndDate)
const adminWindowStarted = currentDate.isAfter(checkWindowData.adminStartDate)
const adminWindowClosed = currentDate.isAfter(checkWindowData.adminEndDate)
const canEditArrangements = (!hdfSubmitted && !checkWindowClosed) || config.OVERRIDE_AVAILABILITY_CHECKS
const restartsAvailable = (!hdfSubmitted && checkWindowStarted && !checkWindowClosed) || config.OVERRIDE_AVAILABILITY_CHECKS
const livePinsAvailable = (!hdfSubmitted && checkWindowStarted && !checkWindowClosed && isWithinOpeningHours) || config.OverridePinExpiry
const familiarisationPinsAvailable = (!hdfSubmitted && familiarisationWindowStarted && !familiarisationWindowClosed && isWithinOpeningHours) || config.OverridePinExpiry
const groupsAvailable = !checkWindowClosed || config.OVERRIDE_AVAILABILITY_CHECKS
const accessArrangementsAvailable = businessAvailabilityService.areAccessArrangementsAllowed(checkWindowData)
const hdfAvailable = currentDate.isBetween(checkWindowData.checkStartDate, checkWindowData.adminEndDate)
export function formatDateTime(dateStr, timeZone) {
if (!dateStr) return dateStr;
const dateTime = moment.tz(dateStr, timeZone);
return (
<span>
{' '}
</span>
);
}
import _ from 'underscore'
import moment from 'moment-timezone'
import React from 'react'
import {Utils} from 'nylas-exports'
import {RetinaImg} from 'nylas-component-kit'
import b64Imgs from './email-b64-images'
import {PLUGIN_URL} from '../scheduler-constants'
const TZ = moment.tz(Utils.timeZone).format("z");
export default class ProposedTimeList extends React.Component {
static propTypes = {
draft: React.PropTypes.object,
event: React.PropTypes.object,
inEmail: React.PropTypes.bool,
proposals: React.PropTypes.array.isRequired,
}
static defaultProps = {
draft: {},
inEmail: false,
}
static displyName = "ProposedTimeList";
function AdicionalInfo(obj) {
this.date_expedition = moment.tz(obj.DataExpedicao, "YYYY-MM-DD", zone).format()
this.service_type = obj.desc_tipo_servico
this.sub_status = obj.Desc_SubStatus.trim()
this.updated = moment.tz(obj.data_status, "YYYY-MM-DD HH:mm", zone).format()
this.status = obj.Desc_Status
this.name = obj.nome
this.distributor = obj.Distribuidor
this.phone1 = obj.Phone1
this.phone2 = obj.Phone2.trim()
this.notes = obj.Notes
this.trackerWebsite = adicional.getLink(null)
}
function oneWeekAhead(date, tz) {
const m = momentTimezone.tz(date, tz);
m.week(m.week() + 1);
return m.toDate();
}