xmcommon
Advanced tools
Comparing version 0.0.20 to 0.0.21
let {CNYCurrency} = require('../lib/cnycurrency'); | ||
let {datetimeUtils} = require('../lib/datetimeUtils'); | ||
@@ -54,4 +55,25 @@ let m = []; | ||
fff(0.15); | ||
fff(5252501.90); | ||
m = []; | ||
let d = new Date('2019-6-28'); | ||
let d2 = new Date('2020-6-16'); | ||
let v = datetimeUtils.diffLocalDaysByDate(d2, d); | ||
let o = 5504180.56; | ||
let vv = 0.0465 * v / 360; | ||
console.log('天数:' + v, '最终费率:' + vv); | ||
let diff = o * vv; | ||
fff(diff); | ||
fff(o - diff); | ||
console.log(o - diff); | ||
console.log((o - diff).toFixed(2)); | ||
let cccc = new CNYCurrency(5504180.56); | ||
let cdiff = cccc.mul(vv); | ||
cccc.selfSub(cdiff.value); | ||
m.push(cccc); | ||
m.push(cdiff); | ||
for(let mm of m) { | ||
@@ -58,0 +80,0 @@ let c2 = mm.Chinese(); |
@@ -129,3 +129,3 @@ // const _ = require("lodash"); | ||
constructor(paramValue = 0) { | ||
if(typeof paramValue === 'CNYCurrency') { | ||
if(CNYCurrency.isCurrency(paramValue)) { | ||
this.m_IntValue = paramValue.m_IntValue; | ||
@@ -149,2 +149,6 @@ this.m_ErrFlag = paramValue.m_ErrFlag; | ||
} | ||
/** 判断指定的对象,是不是指定的CNYCurrency对象 */ | ||
static isCurrency(paramV) { | ||
return paramV instanceof CNYCurrency; | ||
} | ||
@@ -161,3 +165,3 @@ /** 货币值 */ | ||
assign(paramValue = 0) { | ||
if(typeof paramValue === 'CNYCurrency') { | ||
if(CNYCurrency.isCurrency(paramValue)) { | ||
this.m_IntValue = paramValue.m_IntValue; | ||
@@ -164,0 +168,0 @@ this.m_ErrFlag = paramValue.m_ErrFlag; |
@@ -301,6 +301,6 @@ //这里将提供日期相关的工具函数 | ||
/** | ||
* 取本地时间相关的天数 | ||
* 比较本地时间相关的天数差 | ||
* @param {number} paramUTC1 毫秒数 | ||
* @param {number} paramUTC2 毫秒数 | ||
* @return {number} 相关的开数,同一天,返回0 | ||
* @return {number} 相差的天数,同一天,返回0 | ||
*/ | ||
@@ -311,2 +311,14 @@ static diffLocalDays(paramUTC1, paramUTC2) { | ||
return t1 - t2; | ||
} | ||
/** | ||
* 比较两个日期本地时间的天数差 | ||
* @param {Date} paramDate1 日期1 | ||
* @param {Date} paramDate2 日期2 | ||
* @return {number} 相差的天数,同一天,返回0 | ||
*/ | ||
static diffLocalDaysByDate(paramDate1, paramDate2) { | ||
let t1 = this.CalcLocalDaysByUTC(paramDate1.getTime()); | ||
let t2 = this.CalcLocalDaysByUTC(paramDate2.getTime()); | ||
return t1 - t2; | ||
} | ||
@@ -313,0 +325,0 @@ |
{ | ||
"name": "xmcommon", | ||
"version": "0.0.20", | ||
"version": "0.0.21", | ||
"description": "javascript common lib for es6", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -34,2 +34,9 @@ # xmcommon | ||
## 0.0.21 | ||
- 2019-06-28 | ||
- \* fixbug: 不能正确识别增加CNYCurrency类型的对象 | ||
- \+ 增加CNYCurrency.isCurrency函数,判断是否是CNYCurrency类型 | ||
- \+ datetimeUtils增加比较日期的时间差函数 | ||
## 0.0.20 | ||
@@ -36,0 +43,0 @@ |
@@ -861,10 +861,17 @@ // Type definitions for xmcommon 0.0 | ||
/** | ||
* 取本地时间相关的天数 | ||
* @param {number} paramUTC1 毫秒数 | ||
* @param {number} paramUTC2 毫秒数 | ||
* @return {number} 相关的开数,同一天,返回0 | ||
*/ | ||
static diffLocalDays(paramUTC1:number, paramUTC2:number):number; | ||
/** | ||
* 用时间戳的时间比较本地时间相关的天数差 | ||
* @param paramUTC1 时间戳1,毫秒数 | ||
* @param paramUTC2 时间戳2,毫秒数 | ||
* @return 相差的天数,同一天,返回0 | ||
*/ | ||
static diffLocalDays(paramUTC1:number, paramUTC2:number): number; | ||
/** | ||
* 比较两个日期本地时间的天数差 | ||
* @param paramDate1 日期1 | ||
* @param paramDate2 日期2 | ||
* @return 相差的天数,同一天,返回0 | ||
*/ | ||
static diffLocalDaysByDate(paramDate1: Date, paramDate2: Date): number; | ||
/** | ||
@@ -1058,3 +1065,5 @@ * 计算,元年到指定时间戳的本地天数 | ||
*/ | ||
public constructor(paramValue: number | string | CNYCurrency | null | undefined); | ||
public constructor(paramValue: number | string | CNYCurrency | null | undefined); | ||
/** 判断指定的对象,是不是指定的CNYCurrency对象 */ | ||
public static isCurrency(paramV: any): boolean; | ||
/** 货币值 */ | ||
@@ -1061,0 +1070,0 @@ public readonly value : number; |
132503
3881
193