DateTime objects in many programming languages describe an instant in time, expressed as a date and time of day.

learn more… | top users | synonyms

1
vote
0answers
43 views

My AJAX LiveDateTime Object

The following JS code object displays the date and time and updates whenever it changes. It has a sendAjaxRequest() function dependency to make the AJAX requests. ...
6
votes
2answers
75 views

Age in years at a specific date

For eligibility to events I need to know the age of a competitor at a specific date. Now the thing is the date calculations are checked in two places, an online PHP app where the entries are ...
1
vote
0answers
62 views

Calendar application with shaky Logic

I have built a calendar application just with jQuery. The script file is on Github. The code works perfectly fine and I have tested it. Please feel free to clone and test as well. I am uncertain on ...
0
votes
2answers
51 views

Input and Validate Dates

Question: Write a function that accepts integer values for day, month and year and returns them in a valid format. If the day is above 30, then convert it to 30. If the month is above 12 then ...
3
votes
2answers
40 views

Time Code with Microsecond Conversion

The function below converts a time code into seconds, while maintaining the decimal value (fractions of seconds). The time code fed to this function will always contain microseconds. This currently ...
3
votes
4answers
514 views

Calculate next working day

I have tried to tackle this question as follows: ...
1
vote
0answers
22 views

Time calculation to identify current phase

I have a program that works by periodic phases, and I need to understand, depending on the current time, which phase should be executed. The following is not for busy wait, it's just a check. I'm ...
1
vote
2answers
70 views

Checking whether a timestamp is 10 minutes old

I have a timestamp (searchTimestamp) which I need to check to see whether it is less than 10 minutes old or not: ...
12
votes
4answers
534 views

Generating an ordinal number for the day of the month

I am relatively new to programming and came across an if statement that I believe to be a bit verbose. I have tested my code and it appears to work without any ...
2
votes
0answers
57 views

Map Events From calendar provider to dates in gridview

I working on a calendar app on Android, using roomaorama, which is nice. I am fetching all the events from Events table in Calendar provider once which seems not good performance wise. The library ...
7
votes
3answers
291 views

Convert Integer to Date in Java

Due to some clueless soul, we have several fields in a legacy database that uses a 6-digit integer to represent a date in (YYYYmm) format. The date field is assumed to be the last day of the given ...
2
votes
1answer
57 views

Getting duration between two dates

I'm developing on a web application where I have a start and a finish date and time and have to set the duration between it. There are inputs for dates and times. Then, I have this function which ...
2
votes
1answer
37 views

Date-filtering function

Please check if this date filtering function is inefficient code. It seems so to me, but I can't figure out the other way around it. ...
1
vote
1answer
56 views

Sort by a custom date field

I've got this code to work, but being really new to PHP, I don't know if this is proper. I've sorted a CPT loop by a custom date. I'm displaying items from most recent (or future date) to oldest if ...
3
votes
1answer
51 views

JavaScript/jQuery DatePicker

I created some functionality for JavaScript datepicker. I'm trying to store a value in the datepicker with the selected month along with which half it is. To do ...
1
vote
0answers
20 views

Complete date ranges for two years

I have array contents with some date ranges, fetched from the database: ...
1
vote
0answers
12 views

Average interval between dates with random blanks updated

After getting some help at Average interval between dates with random blanks, I rewrote most of the code. Here is the updated code: I have a spreadsheet with order date data: I need to find the ...
2
votes
2answers
88 views

Displaying current date and time using JavaScript and HTML time tag

I am creating a simple support ticket system. I thought It would be a nice little feature to show the current date and time. Since I want to show the current time I thought JavaScript would be best ...
1
vote
1answer
15 views

Finding the year using strtotime vs calculating manually

I need to calculate at which year a school class has started, given the year they currently are in. For example a class of 2nd graders have started school in 2013, if I pass 2 to the function it ...
0
votes
1answer
53 views

Colour-changing clock

I am fairly new to javascript and I would like to write my code on a more readable and efficient way. Any critique of what I've written would be greatly appreciated, especially the section of ...
3
votes
0answers
20 views

Identifying surface events happening at specific time intervals

Here is some code I wrote to surface Mint.com transactions that occur at monthly intervals, in order to identify subscriptions I may be paying for without realizing it. I'd like to have some friends ...
1
vote
1answer
59 views

Random retrievable number based on day and month

I wrote a function to get a 2-digit random number for each day, but it should be retrievable. For example, today's random number is 72, but later I can provide "day and month" and get this 72 again. ...
8
votes
2answers
324 views

Calculating epoch seconds

Below I have code that calculates epoch seconds. It is built to try to change run time checks into asserts in order to give performance in production. I want to make sure all the edge cases are ...
3
votes
4answers
89 views

Formatting MMyyyy to MMyy

The following is my sample code: String month = "09"; String year = "2014"; String monthYear = "092014"; The monthYear format is MMyyyy, I wish to format it to ...
4
votes
1answer
48 views

Average interval between dates with random blanks

I have a spreadsheet with order date data: I need to find the average interval in days between each order date. I have to both find a way to get past the blank cells in the row, and also take into ...
-1
votes
2answers
62 views

Classifying duration as <1, 1-2, 2-3, or >3 years

How can I refactor this method to look cleaner and free from 2 If statements? ...
8
votes
3answers
474 views

Get values between two dates

I have a search form where users can enter ValidFrom and ValidTo dates, There are three conditions: ...
2
votes
1answer
63 views

Formatting a date range, with shortening if the interval falls entirely within a calendar month

The graphic guy wants to display dates like 16. February 17. - 24. February, or ...
3
votes
3answers
118 views

Converting click count data to JSON

I have an array filled with 5 other arrays that consists of arrays of 2 values (first a date then a count): ...
2
votes
1answer
36 views

Print last Sunday of each month in a given year

I'm an experienced programmer trying to learn OCaml. I figured a good way to do that would be to pick a simple task on Rosetta code that didn't yet have an OCaml example and do it myself. With that in ...
3
votes
1answer
54 views

Parse data into three logs

In the bit of code below: How can I make add_day, add_ week and add_month work as a single ...
2
votes
2answers
137 views

Timecode class design

I've created a Timecode class. The "timecode" that I'm trying to represent is a timecode that is used in video editing quite often, and is seen displayed in the ...
1
vote
1answer
54 views

Handling overwriting of unique Dictionary values

I am working in C# to write a scheduling application for operations in a factory. I have a custom class Workday, with properties to represent a ...
5
votes
1answer
85 views

Speeding up Python date conversion function currently using list comprehension and datetime

I am reading a large data file where the time is given in number of days since some epoch. I am currently converting this to Python's datetime format using this function: ...
1
vote
2answers
244 views

Recurring dates auto selection using jQuery UI multiDatesPicker

I setup my code at jsfiddle. Along the review I want to know the solution of a problem I'm facing in this code. On click the Edit button I want to enable the calendar which is disabled by default. ...
5
votes
3answers
176 views

Calculate elapsed time from input times without using conditional statements

I have just started programming and we are being taught C++. After our 2nd lecture we were given an assignment to make a program that would take two values of time from the user (0 <= hr <= 12 ...
3
votes
3answers
157 views

Recurring dates within a range

I'm using this code to find out the recurring dates, within a given range. Is this the correct way to find out the recurring dates within a range of dates? ...
3
votes
0answers
46 views

Calculate compilation time from AssemblyVersion attribute

In my program, I display the compilation time which is calculated from the AssemblyVersion attribute. The attribute is set to automatically generate a version ...
4
votes
1answer
80 views

New year countdown

Here's some code I wrote quickly to get a nice millisecond countdown going. It displays the number of milliseconds until the new year in whatever timezone is next to be in 2015 are in in huge font, ...
1
vote
1answer
47 views

Navigating calendar by week

I started actually learning a little programming last year, as opposed to just hacking away at libraries and found fragments. For a WordPress plugin I needed to navigate through weeks, which I ...
4
votes
1answer
155 views

Convert number into hours : minutes

I wrote a simple extension to convert a number into a hours and minutes string in the ##:## format. This seems like a good way to do it, but let me know what you think. ...
5
votes
2answers
67 views

Join two collections by date with no duplicate

Data I have 4 Collection objects of the following kind: ...
3
votes
0answers
111 views

Scraping efficiently with mechanize and bs4

I have written some code that scrapes data on asteroids, but the problem is that is super slow! I understand that it has a lot to scrape, but as of now it has been running for 5 days and is bot even a ...
11
votes
1answer
66 views

New Moon (not Twilight) Calculator

Photography is one of my hobbies, and, living in Canada, I have the possibility of seeing, and photographing, the Aurora Borealis (Northern Lights). Now, these happen when there's ionization in the ...
4
votes
3answers
70 views

Loop through all virtualhost log files and run goaccess on each file

So I have multiple websites running under apache2 virtualhost - and I wanted to use GoAccess to process the access.log for each site. The directory structure is ...
2
votes
1answer
23 views

Custom moment formats based on string length

Just wanted to gage how solid this code is. With moment cracking down on lazy formatting I thought this was a good way to parse the string for what format to use. ...
10
votes
2answers
1k views

It's almost Friday, right?

This is my final post for my CS1 saga. Mostly all I had to do was just "class-ify" my past project in this post. Here are the requirements: Make all data members private and use constructors, ...
4
votes
3answers
99 views

On What Day Is That Date

I got bored on my long weekend so I decided to have my coding exercise. And I successfully made a program that let you input the day and the month then it gives you the day of given date. But sadly ...
7
votes
2answers
269 views

Set theory clock code

I wrote some JS to power an HTML/CSS "set theory" clock, and I'd like to share what I have so far and ask if anyone can suggest improvements. Specifically, I'm wondering: Should I bother checking ...
3
votes
1answer
50 views

Changing cuts to sed for parsing dates from apache log (common log file)

Would switching my cuts below to SED improve performance? I am trying to get a per date count of requests for the last two weeks from a server log. The script runs, but slowly (comes in around 14 ...