How to use the @jupyterlab/coreutils.Time.format function in @jupyterlab/coreutils

To help you get started, we’ve selected a few @jupyterlab/coreutils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yuvipanda / simplest-notebook / packages / filebrowser / src / listing.ts View on Github external
icon.classList.add(NOTEBOOK_MATERIAL_ICON_CLASS);
        break;
      case 'file':
        icon.classList.add(this.parseFileExtension(model.path));
        break;
      default:
        icon.classList.add(MATERIAL_ICON_CLASS);
        icon.classList.add(FILE_TYPE_CLASS);
        break;
      }

      let modText = '';
      let modTitle = '';
      if (model.last_modified) {
        modText = Time.formatHuman(model.last_modified);
        modTitle = Time.format(model.last_modified);
      }

      // If an item is being edited currently, its text node is unavailable.
      if (text) {
        text.textContent = model.name;
      }

      modified.textContent = modText;
      modified.title = modTitle;
    }
github jupyterlab / jupyterlab-data-explorer / jupyterlab / packages / filebrowser / src / listing.ts View on Github external
} else {
        icon.textContent = '';
        icon.className = ITEM_ICON_CLASS;
      }

      node.title = model.name;
      // If an item is being edited currently, its text node is unavailable.
      if (text) {
        text.textContent = model.name;
      }

      let modText = '';
      let modTitle = '';
      if (model.last_modified) {
        modText = Time.formatHuman(new Date(model.last_modified));
        modTitle = Time.format(new Date(model.last_modified), 'lll');
      }
      modified.textContent = modText;
      modified.title = modTitle;
    }
github jupyterlab / jupyterlab / packages / filebrowser / src / listing.ts View on Github external
icon.textContent = '';
        // clean up the svg icon annotation, if any
        delete icon.dataset.icon;
      }

      node.title = model.name;
      // If an item is being edited currently, its text node is unavailable.
      if (text && text.textContent !== model.name) {
        text.textContent = model.name;
      }

      let modText = '';
      let modTitle = '';
      if (model.last_modified) {
        modText = Time.formatHuman(new Date(model.last_modified));
        modTitle = Time.format(new Date(model.last_modified), 'lll');
      }
      modified.textContent = modText;
      modified.title = modTitle;
    }
github jupyterlab / jupyterlab-data-explorer / tests / test-coreutils / src / time.spec.ts View on Github external
it('should convert a timestring to a date format', () => {
        expect(Time.format(new Date()).length).to.equal(16);
        const date = new Date();
        const value = Time.format(date.toISOString(), 'MM-DD');
        expect(value.length).to.equal(5);
      });
    });
github jupyterlab / jupyterlab-data-explorer / tests / test-coreutils / src / time.spec.ts View on Github external
it('should convert a timestring to a date format', () => {
        expect(Time.format(new Date()).length).to.equal(16);
        const date = new Date();
        const value = Time.format(date.toISOString(), 'MM-DD');
        expect(value.length).to.equal(5);
      });
    });
github yuvipanda / simplest-notebook / packages / console / src / panel.ts View on Github external
function updateTitle(panel: ConsolePanel, connected: Date | null, executed: Date | null) {
    let session = panel.console.session;
    let caption = (
      `Name: ${session.name}\n` +
      `Directory: ${PathExt.dirname(session.path)}\n` +
      `Kernel: ${session.kernelDisplayName}`
    );
    if (connected) {
      caption += `\nConnected: ${Time.format(connected.toISOString())}`;
    }
    if (executed) {
      caption += `\nLast Execution: ${Time.format(executed.toISOString())}`;
    }
    panel.title.label = session.name;
    panel.title.caption = caption;
  }
}
github jupyterlab / jupyterlab-data-explorer / packages / docmanager / src / widgetmanager.ts View on Github external
.then((checkpoints: Contents.ICheckpointModel[]) => {
        if (widget.isDisposed) {
          return;
        }
        let last = checkpoints[checkpoints.length - 1];
        let checkpoint = last ? Time.format(last.last_modified) : 'None';
        let caption = `Name: ${model.name}\nPath: ${model.path}\n`;
        if (context.model.readOnly) {
          caption += 'Read-only';
        } else {
          caption +=
            `Last Saved: ${Time.format(model.last_modified)}\n` +
            `Last Checkpoint: ${checkpoint}`;
        }
        widget.title.caption = caption;
      });
  }
github jupyterlab / jupyterlab / packages / docmanager / src / widgetmanager.ts View on Github external
.then((checkpoints: Contents.ICheckpointModel[]) => {
        if (widget.isDisposed) {
          return;
        }
        let last = checkpoints[checkpoints.length - 1];
        let checkpoint = last ? Time.format(last.last_modified) : 'None';
        let caption = `Name: ${model.name}\nPath: ${model.path}\n`;
        if (context.readOnly) {
          caption += 'Read-only';
        } else {
          caption +=
            `Last Saved: ${Time.format(model.last_modified)}\n` +
            `Last Checkpoint: ${checkpoint}`;
        }
        widget.title.caption = caption;
      });
  }
github jupyterlab / jupyterlab / packages / docmanager / src / widgetmanager.ts View on Github external
.then((checkpoints: Contents.ICheckpointModel[]) => {
        if (widget.isDisposed) {
          return;
        }
        let last = checkpoints[checkpoints.length - 1];
        let checkpoint = last ? Time.format(last.last_modified) : 'None';
        let caption = `Name: ${model.name}\nPath: ${model.path}\n`;
        if (context.readOnly) {
          caption += 'Read-only';
        } else {
          caption +=
            `Last Saved: ${Time.format(model.last_modified)}\n` +
            `Last Checkpoint: ${checkpoint}`;
        }
        widget.title.caption = caption;
      });
  }
github jupyterlab / jupyterlab-data-explorer / packages / docmanager / src / widgetmanager.ts View on Github external
.then((checkpoints: Contents.ICheckpointModel[]) => {
        if (widget.isDisposed) {
          return;
        }
        let last = checkpoints[checkpoints.length - 1];
        let checkpoint = last ? Time.format(last.last_modified) : 'None';
        let caption = `Name: ${model.name}\nPath: ${model.path}\n`;
        if (context.model.readOnly) {
          caption += 'Read-only';
        } else {
          caption +=
            `Last Saved: ${Time.format(model.last_modified)}\n` +
            `Last Checkpoint: ${checkpoint}`;
        }
        widget.title.caption = caption;
      });
  }