Skip to content

Commit

Permalink
feat: global dataInRange
Browse files Browse the repository at this point in the history
  • Loading branch information
LeleDallas committed May 5, 2023
1 parent 7441a2f commit 6651538
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/globalUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import TweenOne from 'rc-tween-one';
import { GetItem } from './types';
import { UploadRequestOption } from "rc-upload/lib/interface";
import { MenuProps } from 'antd/lib/menu';
import moment from 'moment';

export const isImg = /^http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w-./?%&=]*)?/;
export const getChildrenToRender = (item: any, i: number) => {
Expand Down Expand Up @@ -308,3 +309,17 @@ export const uploadImage = async (file: UploadRequestOption, setCurrent: (arg: a
}
}


export const dataInRange = (
el: any,
elec: Array<any>,
gas: Array<any>,
water: Array<any>,
momentSpan: moment.Moment,
) => {
if (moment(el.date).isBetween(momentSpan, undefined, 'day')) {
elec.push([moment.utc(el.date).local().format(), el.electric])
gas.push([moment.utc(el.date).local().format(), el.gas])
water.push([moment.utc(el.date).local().format(), el.water])
}
}

0 comments on commit 6651538

Please sign in to comment.