File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -93,13 +93,20 @@ export function year(det: Dat) {
9393 * @return {bigint } x The urbit date as bigint
9494 */
9595export function parseDa ( x : string ) : bigint {
96- const [ date , time , ms ] = x . split ( '..' ) ;
97- const [ yer , month , day ] = date . slice ( 1 ) . split ( '.' ) ;
96+ let pos = true ;
97+ let [ date , time , ms ] = x . split ( '..' ) ;
98+ time = time || '0.0.0' ;
99+ ms = ms || '0000' ;
100+ let [ yer , month , day ] = date . slice ( 1 ) . split ( '.' ) ;
101+ if ( yer . at ( - 1 ) === '-' ) {
102+ yer = yer . slice ( 0 , - 1 ) ;
103+ pos = false ;
104+ }
98105 const [ hour , minute , sec ] = time . split ( '.' ) ;
99106 const millis = ms . split ( '.' ) . map ( ( m ) => BigInt ( '0x' + m ) ) ;
100107
101108 return year ( {
102- pos : true ,
109+ pos : pos ,
103110 year : BigInt ( yer ) ,
104111 month : BigInt ( month ) ,
105112 time : {
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ export type coin = ({ type: 'dime' } & dime)
4848//TODO rewrite with eye towards capturing groups?
4949export const regex : { [ key in aura ] : RegExp } = {
5050 'c' : / ^ ~ \- ( ( ~ [ 0 - 9 a - f A - F ] + \. ) | ( ~ [ ~ \. ] ) | [ 0 - 9 a - z \- \. _ ] ) * $ / ,
51- 'da' : / ^ ~ ( 0 | [ 1 - 9 ] [ 0 - 9 ] * ) \- ? \. ( [ 1 - 9 ] | 1 [ 0 - 2 ] ) \. ( [ 1 - 9 ] | [ 1 - 3 ] [ 0 - 9 ] ) ( \. \. ( 0 | [ 1 - 9 ] [ 0 - 9 ] * ) \. ( 0 | [ 1 - 9 ] [ 0 - 9 ] * ) \. ( 0 | [ 1 - 9 ] [ 0 - 9 ] * ) ( \. ( \. [ 0 - 9 a - f ] { 4 } ) + ) ? ) ? $ / ,
51+ 'da' : / ^ ~ ( 0 | [ 1 - 9 ] [ 0 - 9 ] * ) \- ? \. ( [ 1 - 9 ] | 1 [ 0 - 2 ] ) \. ( [ 1 - 9 ] | [ 1 - 3 ] [ 0 - 9 ] ) ( \. \. ( [ 0 - 9 ] + ) \. ( [ 0 - 9 ] + ) \. ( [ 0 - 9 ] + ) ( \. ( \. [ 0 - 9 a - f ] { 4 } ) + ) ? ) ? $ / ,
5252 'dr' : / ^ ~ ( ( d | h | m | s ) ( 0 | [ 1 - 9 ] [ 0 - 9 ] * ) ) ( \. ( d | h | m | s ) ( 0 | [ 1 - 9 ] [ 0 - 9 ] * ) ) ? ( \. ( \. [ 0 - 9 a - f ] { 4 } ) + ) ? $ / ,
5353 'f' : / ^ \. ( y | n ) $ / ,
5454 'n' : / ^ ~ $ / ,
Original file line number Diff line number Diff line change @@ -307,11 +307,14 @@ const DATE_TESTS: {
307307 { 'n' : 170141184492616163062707000439658774528n ,
308308 'da' : '~2000.1.1..11.11.11..aabb.0000'
309309 } ,
310+ { 'n' : 170141184492616163062707000439658774528n ,
311+ 'da' : '~2000.1.1..11.11.11..aabb'
312+ } ,
310313 { 'n' : 170141184492615487727406687186543706111n ,
311314 'da' : '~2000.1.1..1.1.1..aabb.ccdd.eeff.ffff'
312315 }
313316] ;
314- testAuras ( 'phonetic ' , DATE_AURAS , DATE_TESTS ) ;
317+ testAuras ( 'date ' , DATE_AURAS , DATE_TESTS ) ;
315318
316319describe ( 'string decoding' , ( ) => {
317320 it ( 'decodes' , ( ) => {
You can’t perform that action at this time.
0 commit comments