How to use the luxon.DateTime.fromJSDate function in luxon

To help you get started, we’ve selected a few luxon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coralproject / talk / src / core / server / services / users / users.ts View on Github external
user: User,
  password: string,
  now: Date
) {
  if (!user.email) {
    throw new EmailNotSetError();
  }

  const passwordVerified = await verifyUserPassword(user, password, user.email);
  if (!passwordVerified) {
    // We throw a PasswordIncorrect error here instead of an
    // InvalidCredentialsError because the current user is already signed in.
    throw new PasswordIncorrect();
  }

  const deletionDate = DateTime.fromJSDate(now).plus({
    days: SCHEDULED_DELETION_TIMESPAN_DAYS,
  });

  const updatedUser = await scheduleDeletionDate(
    mongo,
    tenant.id,
    user.id,
    deletionDate.toJSDate()
  );

  // TODO: extract out into a common shared formatter
  // this is being duplicated everywhere
  const formattedDate = Intl.DateTimeFormat(tenant.locale, {
    year: "numeric",
    month: "numeric",
    day: "numeric",
github tutao / tutanota / src / calendar / CalendarUtils.js View on Github external
export function getDiffInDays(a: Date, b: Date): number {
	// discard the time and time-zone information
	return Math.floor(DateTime.fromJSDate(a).diff(DateTime.fromJSDate(b), 'day').days)
}
github bpetetot / conference-hall / functions / direct / submission.js View on Github external
const getCfpState = ({ event, userTimezone = 'utc' }) => {
  if (event.type === 'meetup') {
    return event.cfpOpened ? 'opened' : 'closed'
  }

  const { address, cfpDates } = event
  if (isEmpty(cfpDates)) {
    return 'not-started'
  }

  // By default 'Europe/Paris' because now it should be mandatory
  const eventTimezone = get(address, 'timezone.id', 'Europe/Paris')

  const start = DateTime.fromJSDate(cfpDates.start.toDate()).setZone(eventTimezone)
  const end = DateTime.fromJSDate(cfpDates.end.toDate())
    .setZone(eventTimezone)
    .plus({
      hours: 23,
      minutes: 59,
      seconds: 59,
    })
  const today = DateTime.utc().setZone(userTimezone)

  if (today < start) {
    return 'not-started'
  }
  if (today > end) {
    return 'closed'
  }
  return 'opened'
}
github teamleadercrm / ui / stories / playground.js View on Github external
Select,
  StatusBullet,
  Textarea,
  TextBody,
  TextSmall,
  Toast,
  ToastContainer,
  Tooltip,
  QTip,
} from '../src';

import { rows1, rows3 } from './static/data/datagrid';
import options, { groupedOptions } from './static/data/select';
import { LANGUAGES } from './static/data/languages';

const inputPlaceholderToday = DateTime.fromJSDate(new Date())
  .setLocale('nl')
  .toLocaleString(DateTime.DATE_SHORT);

const inputPlaceholderTomorrow = DateTime.fromJSDate(new Date())
  .setLocale('nl')
  .plus({ days: 1 })
  .toLocaleString(DateTime.DATE_SHORT);

const preSelectedDate = DateTime.local()
  .plus({ days: 63 })
  .toJSDate();

const preSelectedRange = {
  selectedStartDate: DateTime.local()
    .plus({ days: 3 })
    .toJSDate(),
github kiwicom / smart-faq / src / common / booking / utils.js View on Github external
export const isUrgentBooking = (
  isPastBooking: boolean,
  departureTime: ?Date,
) => {
  const timeDelta = departureTime
    ? DateTime.fromJSDate(departureTime, { zone: 'utc' }).diffNow('hours').hours
    : null;
  const isUrgent = timeDelta !== null && URGENCY_THRESHOLD > timeDelta;

  return isPastBooking === false && isUrgent;
};
github Thorium-Sim / thorium / src / components / views / CoreFeed / index.js View on Github external
onClick={() => this.ignoreCoreFeed(c.id)}
                        >
                          Ignore
                        
                      
                    
                  );
                }
                return (
                  <div>
                    <div> this.showComponent(c.id)}
                    &gt;
                      <strong>
                        {DateTime.fromJSDate(
                          new Date(parseInt(c.timestamp)),
                        ).toFormat("h:mm:ssa")}{" "}
                        - {c.title}
                      </strong>
                      {c.body &amp;&amp; <p>{c.body}</p>}
                       {
                          e.preventDefault();
                          e.stopPropagation();
                          this.ignoreCoreFeed(c.id);
                        }}
                      /&gt;
                    </div>
                  </div>
                );
github Azure / BatchExplorer / src / @batch-flask / ui / timespan / timespan.component.ts View on Github external
private _computeTimespan() {
        if (!this.startTime && !this.endTime) { return null; }
        const startTime = this.startTime ? DateTime.fromJSDate(this.startTime) : this.now();
        const endTime = this.endTime ? DateTime.fromJSDate(this.endTime) : this.now();
        return endTime.diff(startTime);
    }
github Azure / BatchExplorer / src / @batch-flask / core / aad / access-token / access-token.model.ts View on Github external
public expireInLess(milliseconds: number): boolean {
        const expireIn = DateTime.fromJSDate(this.expires_on).diff(DateTime.utc()).as("milliseconds");
        return expireIn &lt; milliseconds;
    }
github zachleat / zachleat.com / .eleventy.js View on Github external
eleventyConfig.addFilter("readableDate", dateObj => {
		return DateTime.fromJSDate(dateObj).toFormat("LLLL dd, yyyy");
	});
github Azure / BatchExplorer / src / app / components / job / graphs / all-job-graphs-home / jobs-cpu-wait-time-graph / jobs-cpu-wait-time-graph.component.ts View on Github external
public getTooltip(job: Job) {
        const runningTime = DateTime.fromJSDate(job.executionInfo.endTime).diff(
            DateTime.fromJSDate(job.executionInfo.startTime));
        return [
            `Job id: ${job.id}`,
            "",
            `Running time: ${DateUtils.compactDuration(runningTime, true)}`,
            `Cpu time: ${DateUtils.compactDuration(job.stats.userCPUTime, true)}`,
            `Waiting time: ${DateUtils.compactDuration(job.stats.waitTime, true)}`,
        ];
    }
}