Index: wp-includes/default-filters.php
===================================================================
--- wp-includes/default-filters.php	(revision 3513)
+++ wp-includes/default-filters.php	(working copy)
@@ -84,5 +84,6 @@
 // Actions
 add_action('publish_post', 'generic_ping');
 add_action('wp_head', 'rsd_link');
+add_action('publish_future_post', 'wp_publish_post', 10, 1);
 
 ?>
\ No newline at end of file
Index: wp-includes/template-functions-general.php
===================================================================
--- wp-includes/template-functions-general.php	(revision 3513)
+++ wp-includes/template-functions-general.php	(working copy)
@@ -327,10 +327,8 @@
 	$add_hours = intval(get_settings('gmt_offset'));
 	$add_minutes = intval(60 * (get_settings('gmt_offset') - $add_hours));
 
-	$now = current_time('mysql');
-
 	if ( 'monthly' == $type ) {
-		$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
+		$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
 		if ( $arcresults ) {
 			$afterafter = $after;
 			foreach ( $arcresults as $arcresult ) {
@@ -345,7 +343,7 @@
 			}
 		}
 	} elseif ( 'daily' == $type ) {
-		$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_date != '0000-00-00 00:00:00' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+		$arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
 		if ( $arcresults ) {
 			foreach ( $arcresults as $arcresult ) {
 				$url	= get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth);
@@ -356,7 +354,7 @@
 		}
 	} elseif ( 'weekly' == $type ) {
 		$start_of_week = get_settings('start_of_week');
-		$arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+		$arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
 		$arc_w_last = '';
 		if ( $arcresults ) {
 				foreach ( $arcresults as $arcresult ) {
@@ -373,7 +371,7 @@
 				}
 		}
 	} elseif ( 'postbypost' == $type ) {
-		$arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
+		$arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC" . $limit);
 		if ( $arcresults ) {
 			foreach ( $arcresults as $arcresult ) {
 				if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {
Index: wp-includes/version.php
===================================================================
--- wp-includes/version.php	(revision 3513)
+++ wp-includes/version.php	(working copy)
@@ -3,6 +3,6 @@
 // This just holds the version number, in a separate file so we can bump it without cluttering the SVN
 
 $wp_version = '2.1-aplha1';
-$wp_db_version = 3513;
+$wp_db_version = 3514;
 
 ?>
\ No newline at end of file
Index: wp-includes/functions-post.php
===================================================================
--- wp-includes/functions-post.php	(revision 3513)
+++ wp-includes/functions-post.php	(working copy)
@@ -72,6 +72,9 @@
 			$post_date_gmt = get_gmt_from_date($post_date);
 	}
 
+	if ( 'publish' == $post_status && (mysql2date('U', $post_date_gmt) > time()) )
+		$post_status = 'future';
+
 	if ( empty($comment_status) ) {
 		if ( $update )
 			$comment_status = 'closed';
@@ -204,6 +207,9 @@
 				add_post_meta($post_ID, '_wp_page_template',  $page_template, true);
 	}
 
+	if ( 'future' == $post_status )
+		wp_schedule_event(mysql2date('U', $post_date_gmt), 'once', 'publish_future_post', $post_ID);
+
 	do_action('save_post', $post_ID);
 	do_action('wp_insert_post', $post_ID);
 
@@ -455,6 +461,18 @@
 	return wp_insert_post($postarr);
 }
 
+function wp_publish_post($post_id) {
+	$post = get_post($post_id);
+
+	if ( empty($post) )
+		return;
+
+	if ( 'publish' == $post->post_status )
+		return;
+
+	return wp_update_post(array('post_status' => 'publish', 'ID' => $post_id));	
+}
+
 function wp_get_post_cats($blogid = '1', $post_ID = 0) {
 	global $wpdb;
 	
Index: wp-includes/classes.php
===================================================================
--- wp-includes/classes.php	(revision 3513)
+++ wp-includes/classes.php	(working copy)
@@ -571,14 +571,14 @@
 			}
 		}
 
-		$now = gmdate('Y-m-d H:i:59');
+		//$now = gmdate('Y-m-d H:i:59');
 		
 		//only select past-dated posts, except if a logged in user is viewing a single: then, if they
 		//can edit the post, we let them through
-		if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
-			$where .= " AND post_date_gmt <= '$now'";
-			$distinct = 'DISTINCT';
-		}
+		//if ($pagenow != 'post.php' && $pagenow != 'edit.php' && !($this->is_single && $user_ID)) {
+		//	$where .= " AND post_date_gmt <= '$now'";
+		//	$distinct = 'DISTINCT';
+		//}
 
 		if ( $this->is_attachment ) {
 			$where .= ' AND (post_type = "attachment")';
@@ -589,7 +589,12 @@
 		} else {
 			$where .= ' AND (post_type = "post" AND post_status = "publish"';
 
-			if (isset($user_ID) && ('' != intval($user_ID)))
+			if ( $pagenow == 'post.php' || $pagenow == 'edit.php' )
+				$where .= " OR post_status = 'future'";
+			else
+				$distinct = 'DISTINCT';
+	
+			if ( is_user_logged_in() )
 				$where .= " OR post_author = $user_ID AND post_status = 'private')";
 			else
 				$where .= ')';				
@@ -641,6 +646,7 @@
 		// Check post status to determine if post should be displayed.
 		if ($this->is_single || $this->is_page) {
 			$status = get_post_status($this->posts[0]);
+			//$type = get_post_type($this->posts[0]);
 			if ( ('publish' != $status) ) {
 				if ( ! is_user_logged_in() ) {
 					// User must be logged in to view unpublished posts.
@@ -654,18 +660,16 @@
 							$this->is_preview = true;
 							$this->posts[0]->post_date = current_time('mysql');
 						}
+					}  else if ('future' == $status) {
+						$this->is_preview = true;
+						if (!current_user_can('edit_post', $this->posts[0]->ID)) {
+							$this->posts = array ( );
+						}
 					} else {
 						if (! current_user_can('read_post', $this->posts[0]->ID))
 							$this->posts = array();
 					}
 				}
-			} else {
-				if (mysql2date('U', $this->posts[0]->post_date_gmt) > mysql2date('U', $now)) { //it's future dated
-					$this->is_preview = true;
-					if (!current_user_can('edit_post', $this->posts[0]->ID)) {
-						$this->posts = array ( );
-					}
-				}
 			}
 		}
 
Index: wp-includes/template-functions-links.php
===================================================================
--- wp-includes/template-functions-links.php	(revision 3513)
+++ wp-includes/template-functions-links.php	(working copy)
@@ -294,9 +294,7 @@
 		$posts_in_ex_cats_sql = 'AND ID NOT IN (' . implode($posts_in_ex_cats, ',') . ')';
 	}
 
-	$now = current_time('mysql');
-	
-	return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_date < '$now' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1");
+	return @$wpdb->get_row("SELECT ID,post_title FROM $wpdb->posts $join WHERE post_date > '$current_post_date' AND post_type = 'post' AND post_status = 'publish' $posts_in_ex_cats_sql AND ID != $post->ID ORDER BY post_date ASC LIMIT 1");
 }
 
 
Index: wp-includes/functions.php
===================================================================
--- wp-includes/functions.php	(revision 3513)
+++ wp-includes/functions.php	(working copy)
@@ -110,17 +110,16 @@
 	global $cache_lastpostdate, $pagenow, $wpdb;
 	$add_seconds_blog = get_settings('gmt_offset') * 3600;
 	$add_seconds_server = date('Z');
-	$now = current_time('mysql', 1);
 	if ( !isset($cache_lastpostdate[$timezone]) ) {
 		switch(strtolower($timezone)) {
 			case 'gmt':
-				$lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+				$lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
 				break;
 			case 'blog':
-				$lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+				$lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
 				break;
 			case 'server':
-				$lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_date_gmt <= '$now' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
+				$lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1");
 				break;
 		}
 		$cache_lastpostdate[$timezone] = $lastpostdate;
@@ -134,17 +133,16 @@
 	global $cache_lastpostmodified, $pagenow, $wpdb;
 	$add_seconds_blog = get_settings('gmt_offset') * 3600;
 	$add_seconds_server = date('Z');
-	$now = current_time('mysql', 1);
 	if ( !isset($cache_lastpostmodified[$timezone]) ) {
 		switch(strtolower($timezone)) {
 			case 'gmt':
-				$lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+				$lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
 				break;
 			case 'blog':
-				$lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+				$lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
 				break;
 			case 'server':
-				$lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_modified_gmt <= '$now' AND post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
+				$lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' ORDER BY post_modified_gmt DESC LIMIT 1");
 				break;
 		}
 		$lastpostdate = get_lastpostdate($timezone);
@@ -1350,12 +1348,10 @@
 	if ( !isset($r['order']) )
 		$r['order'] = 'DESC';
 
-	$now = current_time('mysql');
-
 	$posts = $wpdb->get_results(
 		"SELECT DISTINCT * FROM $wpdb->posts " .
 		( empty( $r['category'] ) ? "" : ", $wpdb->post2cat " ) .
-		" WHERE post_date <= '$now' AND (post_type = 'post' AND post_status = 'publish') ".
+		" WHERE (post_type = 'post' AND post_status = 'publish') ".
 		( empty( $r['category'] ) ? "" : "AND $wpdb->posts.ID = $wpdb->post2cat.post_id AND $wpdb->post2cat.category_id = " . $r['category']. " " ) .
 		" GROUP BY $wpdb->posts.ID ORDER BY " . $r['orderby'] . " " . $r['order'] . " LIMIT " . $r['offset'] . ',' . $r['numberposts'] );
 
Index: wp-settings.php
===================================================================
--- wp-settings.php	(revision 3513)
+++ wp-settings.php	(working copy)
@@ -217,6 +217,7 @@
 
 function shutdown_action_hook() {
 	do_action('shutdown');
+	wp_cron();
 	wp_cache_close();
 }
 register_shutdown_function('shutdown_action_hook');
Index: wp-admin/upgrade-functions.php
===================================================================
--- wp-admin/upgrade-functions.php	(revision 3513)
+++ wp-admin/upgrade-functions.php	(working copy)
@@ -33,7 +33,7 @@
 	if ( $wp_current_db_version < 3308 )
 		upgrade_160();
 
-	if ( $wp_current_db_version < 3513 )
+	if ( $wp_current_db_version < 3514 )
 		upgrade_210();
 
 	$wp_rewrite->flush_rules();
Index: wp-admin/upgrade-schema.php
===================================================================
--- wp-admin/upgrade-schema.php	(revision 3513)
+++ wp-admin/upgrade-schema.php	(working copy)
@@ -106,7 +106,7 @@
   post_title text NOT NULL,
   post_category int(4) NOT NULL default '0',
   post_excerpt text NOT NULL,
-  post_status enum('publish','draft','private','static','object','attachment','inherit') NOT NULL default 'publish',
+  post_status enum('publish','draft','private','static','object','attachment','inherit','future') NOT NULL default 'publish',
   comment_status enum('open','closed','registered_only') NOT NULL default 'open',
   ping_status enum('open','closed') NOT NULL default 'open',
   post_password varchar(20) NOT NULL default '',
