lincd-schema
Advanced tools
Comparing version 0.1.5 to 0.1.6
@@ -15,2 +15,3 @@ import { ShapeSet } from 'lincd/lib/collections/ShapeSet'; | ||
set birthDate(nativeDate: Date); | ||
get age(): number; | ||
get birthPlace(): string; | ||
@@ -17,0 +18,0 @@ set birthPlace(val: string); |
@@ -47,2 +47,14 @@ "use strict"; | ||
} | ||
get age() { | ||
if (this.hasProperty(schema_1.schema.birthDate) === false) | ||
return null; | ||
var today = new Date(); | ||
var birthDate = this.birthDate; | ||
var age = today.getFullYear() - birthDate.getFullYear(); | ||
var m = today.getMonth() - birthDate.getMonth(); | ||
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { | ||
age--; | ||
} | ||
return age; | ||
} | ||
get birthPlace() { | ||
@@ -49,0 +61,0 @@ return this.getValue(schema_1.schema.birthPlace); |
@@ -5,3 +5,3 @@ { | ||
"license": "UNLICENSED", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"lincd": true, | ||
@@ -8,0 +8,0 @@ "author": { |
@@ -65,2 +65,13 @@ import {XSDDate} from 'lincd-xsd/lib/shapes/XSDDate'; | ||
} | ||
get age() { | ||
if (this.hasProperty(schema.birthDate) === false) return null; | ||
var today = new Date(); | ||
var birthDate = this.birthDate; | ||
var age = today.getFullYear() - birthDate.getFullYear(); | ||
var m = today.getMonth() - birthDate.getMonth(); | ||
if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) { | ||
age--; | ||
} | ||
return age; | ||
} | ||
@@ -67,0 +78,0 @@ @literalProperty({ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6624581
101549