Iso8601TimestampView = require './iso8601-timestamp-view'
{CompositeDisposable} = require 'atom'
{TextEditor} = require 'atom'

module.exports = Iso8601Timestamp =

  activate: ->
    atom.commands.add 'atom-workspace', "iso8601-timestamp:iso", => @iso()
    atom.commands.add 'atom-workspace', "iso8601-timestamp:local", => @local()

  iso: ->
    editor = atom.workspace.getActivePaneItem()

    #then, maybe 'new file/ new folder' dialog??
    if editor instanceof TextEditor == false
      panels = atom.workspace.panelContainers.modal.panels
      last = panels[panels.length - 1]
      editor = last.item.miniEditor

    moment = require 'moment'
    iso_time = moment().format('YYYYMMDDTHHmmssZZ_')
    editor.insertText(iso_time)

  local: ->
    editor = atom.workspace.getActivePaneItem()

    #then, maybe 'new file/ new folder' dialog??
    if editor instanceof TextEditor == false
      panels = atom.workspace.panelContainers.modal.panels
      last = panels[panels.length - 1]
      editor = last.item.miniEditor

    moment = require 'moment'
    local_time = moment().format('YYYY/MM/DD, HH:mm:ss, ZZ')
    editor.insertText(local_time)
