type-store 0.4.1 → 0.4.3

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.
Files changed (2) hide show
  1. package/package.json +6 -6
  2. package/type-store.js +38 -4
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "type-store",
3
3
  "description": "type ecosystem",
4
- "version": "0.4.1",
4
+ "version": "0.4.3",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "repository": "codenautas/type-store",
7
7
  "license": "MIT",
@@ -11,16 +11,16 @@
11
11
  "postgres-interval4client.js"
12
12
  ],
13
13
  "dependencies": {
14
- "big.js": "^6.2.1",
15
- "best-globals": "^1.1.4",
14
+ "big.js": "^6.2.2",
15
+ "best-globals": "^1.1.6",
16
16
  "js-to-html": "^1.3.2",
17
- "json4all": "^1.2.1",
18
- "like-ar": "^0.4.0"
17
+ "json4all": "^1.4.0",
18
+ "like-ar": "^0.5.1"
19
19
  },
20
20
  "devDependencies": {
21
21
  "expect.js": "^0.3.1",
22
22
  "istanbul": "^0.4.5",
23
- "mocha": "^10.4.0",
23
+ "mocha": "^10.7.3",
24
24
  "postgres-interval": "^4.0.2",
25
25
  "discrepances": "^0.2.8"
26
26
  },
package/type-store.js CHANGED
@@ -761,11 +761,45 @@ TypeStore.type.timestamp.prototype.toPlainString=function toPlainString(typedVal
761
761
  return typedValue.toYmdHmsM();
762
762
  };
763
763
 
764
- /*
765
- Interval.prototype.toLiteral=function(){
766
- return this.toString();
764
+
765
+ TypeStore.type.time = function TypeArrayTime(){ TypeBase.apply(this, arguments); };
766
+ TypeStore.type.time.prototype = Object.create(TypeBase.prototype);
767
+ TypeStore.type.time.prototype.typeDbPg='time';
768
+ TypeStore.type.time.prototype.pgSpecialParse=true;
769
+ TypeStore.type.time.prototype.toPlainString=function toPlainString(typedValue){
770
+ return typedValue+'';
767
771
  };
768
- */
772
+ TypeStore.type.time.prototype.pg_OID=1083;
773
+ TypeStore.type.time.prototype.partDefs=[
774
+ {name:'hours' , optative:false, sufix:':' },
775
+ {name:'minutes', optative:false, sufix:':' , twoDigits:true },
776
+ {name:'seconds', optative:false, sufix:'' , twoDigits:true },
777
+ ];
778
+ // constructorFunction:new PostgresInterval().constructor,
779
+ TypeStore.type.time.prototype.regExp=/^\s*(?:(\d+)\s*(?:h|:|hours?|horas?))?\s*(?:(\d+)\s*(?:m|:|'|min|minutes?|minutos?)?)?\s*(?:(\d+)\s*(?:s|"|sec|seg|seconds?|segundos?)?)?\s*?$/i;
780
+ TypeStore.type.time.prototype.fromString=function fromString(stringWithTime){
781
+ var value = this.toLocalString(stringWithTime);
782
+ if (value.length <1 ) throw new TypeError("NOT time")
783
+ return value;
784
+ };
785
+ TypeStore.type.time.prototype.isValidTypedData=function isValidTypedData(object){
786
+ return object === null || this.regExp.test(object);
787
+ };
788
+ TypeStore.type.time.prototype.toLocalParts=function toLocalParts(typedValue,fPart,fParts){
789
+ var str = this.toPlainString(typedValue);
790
+ var rta = [];
791
+ str.replace(/^\s*0?([1-2]?\d)\:(\d\d)(\:(\d\d))?$/, function(str, hour, minutes, dot, seconds){
792
+ rta.push(fPart(hour,"time-hour"));
793
+ rta.push(fPart(':',"time-colon"));
794
+ rta.push(fPart(minutes,"time-min"));
795
+ if (seconds != '00' && seconds != null) {
796
+ rta.push(fPart(':',"time-colon"));
797
+ rta.push(fPart(seconds,"time-sec"));
798
+ }
799
+ });
800
+ return fParts(rta, "time");
801
+ };
802
+
769
803
  // PostgresInterval.prototype.typeStore={type:'interval'};
770
804
 
771
805
  json4all.addType(bestGlobals.TimeInterval,{