fix date
This commit is contained in:
		
							parent
							
								
									e9caff8e86
								
							
						
					
					
						commit
						93e493acbb
					
				@ -9,6 +9,7 @@ angular.module('myApp.services', []).
 | 
			
		||||
      reset: function () {
 | 
			
		||||
        desi = {};
 | 
			
		||||
      }
 | 
			
		||||
    , toDesiDate: Desi.toLocaleDate
 | 
			
		||||
    , meta: function () {
 | 
			
		||||
        var d = $q.defer()
 | 
			
		||||
          ;
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										16
									
								
								deardesi.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								deardesi.js
									
									
									
									
									
								
							@ -42,15 +42,6 @@
 | 
			
		||||
    return str;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /*
 | 
			
		||||
  function toLocaleDate(d) {
 | 
			
		||||
    return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()
 | 
			
		||||
      + ' '
 | 
			
		||||
      + (d.getHours() % 12) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds())
 | 
			
		||||
      ;
 | 
			
		||||
  }
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
  function fromLocaleDate(str) {
 | 
			
		||||
    // handles ISO and ISO-ish dates
 | 
			
		||||
    var m = str.match(/(\d\d\d\d)-(\d{1,2})-(\d{1,2})([T\s](\d{1,2}):(\d{1,2})(:(\d{1,2}))?)?/)
 | 
			
		||||
@ -215,6 +206,13 @@
 | 
			
		||||
  function Desi() {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Desi.toLocaleDate = function (d) {
 | 
			
		||||
    return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
 | 
			
		||||
      + ' '
 | 
			
		||||
      + (d.getHours() % 12) + ':' + pad(d.getMinutes()) + ' ' + (d.getHours() - 12 >= 0 ? 'pm' : 'am')
 | 
			
		||||
      ;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  // read config and such
 | 
			
		||||
  Desi.init = function (desi) {
 | 
			
		||||
    // config.yml, data.yml, site.yml, authors
 | 
			
		||||
 | 
			
		||||
@ -36,7 +36,7 @@ angular.module('myApp.post', ['ngRoute'])
 | 
			
		||||
        title: ""
 | 
			
		||||
      , description: ""
 | 
			
		||||
      , uuid: window.uuid.v4()
 | 
			
		||||
      , date: "YYYY-MM-DD HH:MM pm" // TODO desirae
 | 
			
		||||
      , date: Desirae.toDesiDate(new Date())// "YYYY-MM-DD HH:MM pm" // TODO desirae
 | 
			
		||||
      , permalink: "/article/new.md"
 | 
			
		||||
      , categories: []
 | 
			
		||||
      , tags: []
 | 
			
		||||
@ -46,6 +46,7 @@ angular.module('myApp.post', ['ngRoute'])
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
  scope.selected.date = scope.selected.post.yml.date;
 | 
			
		||||
  scope.selected.post.frontmatter = window.jsyaml.dump(scope.selected.post.yml);
 | 
			
		||||
 | 
			
		||||
  scope.onChange = function () {
 | 
			
		||||
@ -55,6 +56,9 @@ angular.module('myApp.post', ['ngRoute'])
 | 
			
		||||
      scope.selected.permalink = '/articles/' + scope.selected.title.toLowerCase()
 | 
			
		||||
        .replace(/["']/g, '')
 | 
			
		||||
        .replace(/\W/g, '-')
 | 
			
		||||
        .replace(/^-/g, '')
 | 
			
		||||
        .replace(/-$/g, '')
 | 
			
		||||
        .replace(/--/g, '-')
 | 
			
		||||
        + '.' + scope.selected.format
 | 
			
		||||
        ;
 | 
			
		||||
      scope.selected.post.yml.permalink = scope.selected.permalink;
 | 
			
		||||
@ -69,13 +73,13 @@ angular.module('myApp.post', ['ngRoute'])
 | 
			
		||||
 | 
			
		||||
  $timeout(function () {
 | 
			
		||||
    if (scope.selected && scope.selected.date === scope.selected.post.yml.date) {
 | 
			
		||||
      scope.selected.date = scope.selected.post.yml.date = new Date().toISOString();
 | 
			
		||||
      scope.selected.date = scope.selected.post.yml.date = Desirae.toDesiDate(new Date());
 | 
			
		||||
    }
 | 
			
		||||
    scope.onChange();
 | 
			
		||||
  }, 60 * 1000);
 | 
			
		||||
 | 
			
		||||
  scope.upsert = function () {
 | 
			
		||||
    console.log(scope.selected.format)
 | 
			
		||||
    console.log(scope.selected.format);
 | 
			
		||||
    var files = []
 | 
			
		||||
      ;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user