File tree Expand file tree Collapse file tree 3 files changed +12
-7
lines changed
Expand file tree Collapse file tree 3 files changed +12
-7
lines changed Original file line number Diff line number Diff line change 3030// undefined, empty or a null image it returns the timestamp NULL.
3131
3232import { Decimal } from "./IonDecimal" ;
33- import { is_digit } from "./IonText" ;
3433import { isNumber } from "./IonUtilities" ;
3534import { isString } from "./IonUtilities" ;
3635import { isUndefined } from "./IonUtilities" ;
@@ -178,7 +177,7 @@ function to_4_digits(v: number) : string {
178177function read_unknown_digits ( str : string , pos : number ) : string {
179178 let i : number = pos ;
180179 for ( ; i < str . length ; i ++ ) {
181- if ( ! isNumber ( str . charCodeAt ( i ) ) ) {
180+ if ( ! isNumber ( parseInt ( str [ i ] , 10 ) ) ) {
182181 break ;
183182 }
184183 }
@@ -501,7 +500,10 @@ export class Timestamp {
501500 break ;
502501 // 1234-67-89T12:45:78.dddd
503502 case States . FRACTIONAL_SECONDS :
504- seconds = Decimal . parse ( str . substr ( 17 , pos - 17 ) ) ;
503+ const START_POSITION_OF_SECONDS = 17 ;
504+
505+ seconds = Decimal . parse ( str . substring ( START_POSITION_OF_SECONDS , pos ) ) ;
506+
505507 break ;
506508 case States . OFFSET :
507509 break ;
Original file line number Diff line number Diff line change 1515 * A collection of general language-level helper methods.
1616 */
1717export function isNumber ( value : any ) : value is number {
18- return typeof ( value ) == 'number' ;
18+ return typeof ( value ) == 'number' && ! isNaN ( value ) ;
1919}
2020
2121export function isString ( value : any ) : value is string {
Original file line number Diff line number Diff line change 1717 const assert = require ( 'intern/chai!assert' ) ;
1818 const ion = require ( 'dist/amd/es6/Ion' ) ;
1919
20- var suite = {
20+ let suite = {
2121 name : 'Timestamp'
2222 } ;
2323
24- var parseTest = function ( name , timestamp ) {
24+ const parseTest = function ( name , timestamp ) {
2525 suite [ name ] = function ( ) {
2626 ion . Timestamp . parse ( timestamp ) ;
2727 }
28- }
28+ } ;
2929
3030 parseTest ( 'Parses year' , '2017T' ) ;
3131 parseTest ( 'Parses month' , '2017-02T' ) ;
32+ // Seconds are optional, but local offset is not.
33+ parseTest ( 'Parses date and time with only hour and minutes' , '2007-02-23T12:14Z' ) ;
34+ parseTest ( 'Parses timestamp: The same instant in UTC ("zero" or "zulu")' , '2017-05-01T01:00:00.000Z' ) ;
3235
3336 registerSuite ( suite ) ;
3437 }
You can’t perform that action at this time.
0 commit comments