@ledvance/base 1.2.62 → 1.2.64

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -325,6 +325,10 @@ export function useUAGroupInfo(): UAGroupInfo {
325
325
  return useSelector(state => state.ldvModules.uaGroupInfo)
326
326
  }
327
327
 
328
+ export function putGroupTYDps(tyGroupId: number, dps: Record<string, any>) {
329
+ return NativeApi.putGroupTYDps(tyGroupId, JSON.stringify(dps))
330
+ }
331
+
328
332
  export function useGroupConfig<T>(): [T, (dps: any, newConfig: T) => Promise<Result<any>>] {
329
333
  const tyGroupId = useUAGroupInfo().tyGroupId
330
334
  const config = useUAGroupInfo().config || {}
@@ -337,3 +337,39 @@ export function convertMinutesTo12HourFormat(minutes: number, is24: boolean) {
337
337
  export function getGlobalParamsDp(key: string) {
338
338
  return GlobalParams.dpSchemaMap[key] && GlobalParams.dpSchemaMap[key].dp.toString()
339
339
  }
340
+
341
+ // 判断时间毫秒数在这一天中多少分钟
342
+ export function getMinutesOfTheDay(milliseconds: number) {
343
+ // 将给定的毫秒数转换为 Date 对象
344
+ const date = new Date(milliseconds);
345
+
346
+ // 获取该日期的起始时间(午夜 00:00:00)的时间戳(毫秒)
347
+ const startOfDay = new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
348
+
349
+ // 计算给定毫秒数与当天起始时间的差值(毫秒)
350
+ const differenceMillis = milliseconds - startOfDay;
351
+
352
+ // 将差值转换为分钟数
353
+ const minutes = Math.floor(differenceMillis / 60000);
354
+
355
+ return minutes;
356
+ }
357
+
358
+ export function getIsClosed(item: {weeks: number[], settingTime: number, endTime: number}){
359
+ const isOnce = item?.weeks?.every(w => w === 0)
360
+ let undone = true
361
+ if(isOnce && item.settingTime){
362
+ const setting = new Date(item.settingTime).toDateString()
363
+ const settingMin = getMinutesOfTheDay(item.settingTime)
364
+ const current = new Date().toDateString()
365
+ const currentMin = getMinutesOfTheDay(new Date().getTime())
366
+ if(setting !== current){
367
+ undone = false
368
+ }else{
369
+ if(settingMin < item.endTime && currentMin > item.endTime){
370
+ undone = false
371
+ }
372
+ }
373
+ }
374
+ return undone
375
+ }