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

learn more… | top users | synonyms

7
votes
3answers
88 views

Simple greeting program based with timezone offset

I made a simple set of functions that returns a greeting based on the current time, the user's timezone offset, and the user's level. For context I wrote this as a part of a larger chat bot ...
5
votes
0answers
40 views

Expressing Rebol Dates in BNF

I'm looking to define the Rebol date format in BNF notation (as adapted for Rebol Parse). I'd like as best as possible to only define valid dates—at least those that are valid in Rebol at the moment: ...
4
votes
1answer
56 views

Expressing Rebol Dates in EBNF

I'm looking to define the Rebol date format in EBNF notation. I'd like as best as possible to only define valid dates—at least those that are valid in Rebol at the moment: ...
3
votes
2answers
128 views

Implementing a Yearmonth class

Recently I wrote a program that was required to handle year and month data and so I wrote this class to encapsulate that handling. What I needed was a way to initialize the ...
2
votes
1answer
23 views

Convert list of UTC to Current TimeZone

I found myself with a list of UTC timestamps and wanted to convert them into the local time zone. Using this web post as a starting point, I modified the script to grab a text file containing UTC ...
5
votes
0answers
150 views
+50

LiveDate version 2

LiveDate has the ability to display the current date either by asynchronously fetching the time from a server or by just using the client system date. It's only as ...
2
votes
1answer
38 views

Generating Calendar month information using JavaScript

I am using the below function to set month information on context passed. It is working fine, but please review it and let me know if there are any potential flaws or any improvements in this code. ...
1
vote
1answer
47 views

Track execution time using std::chrono facilities and print the execution time in a comprehensible way

The class below will be used to track the execution time of various operations. There is no need to dip into C libraries to get formatted output then. Output would be something like this: 10 ...
0
votes
2answers
32 views

Stripping time information in a DateTime object [closed]

Is there any better way to strip the time information in a DateTime Object than creating a new DateTime Object? For example, if I just want today's date and not time, is the only way is to do the ...
1
vote
1answer
43 views

Counting only weekend days between two timestamps

I am fairly new to the Groovy arena. I recently modified some code to add the following block. This code is added to remove dates we were supposed to remove from the total counts. This data goes on ...
3
votes
2answers
29 views

SQL server efficiency, comparing date time of latest record and the one under it

I have a snippet of SQL that compares the last two records and gives the datediff in seconds. However, the way I have it is quite slow, taking up to 20 seconds to execute depending on how many ...
1
vote
1answer
37 views

Implementing a date validator using enum

First and second post on the same subject. This is such a great way to learn. Once again I'm open to suggestions. I have implemented almost all of the suggestions from before, which have resulted in ...
4
votes
1answer
82 views

Using swing and creating JPanel

I watched bunch of videos about swing and GUI in general and created my first component (correct me if it is not one). JPanel class: ...
2
votes
1answer
45 views

Date validation in Java - take two

I read through and implemented the advice I received yesterday. I would, once again, really like some input on how this can be improved. e.g. encapsulation, interfaces, abstract classes etc.. Right ...
2
votes
1answer
34 views

Validate input of month/year, otherwise set it to current month/year

Is there a cleaner way of doing this? I'm using filter_input to first check for valid input, then using it again to assign the variable. Also, my condition in ...
5
votes
2answers
120 views

Unit Tests for getting the first Monday of the month

I have an application that runs hourly, and I want to use it to also send an email at the start of the day of the first Monday of the month. I searched and found information to help me code what I ...
2
votes
1answer
64 views

Date validation in Java

I'm learning Java, and would really appreciate any tips on how to improve this code. It's just a simple date validation class. ...
5
votes
1answer
77 views

jQuery Datepicker Plugin

I created a jQuery plugin that converts a text field to a 3 drop down, datepicker. It allows the user to select a Day, Month and Year rather than type the date in an input box. The original input ...
2
votes
1answer
38 views

Extract incomplete weeks from a DateTime collection

The code below attempts to extract incomplete weeks from a List<DateTime>. For example, a list containing all the days in Jan 2015 would result in the 5th to ...
5
votes
1answer
66 views

Find the next 7 o'clock NSDate

In my very specific scenario, I need to get an NSDate holding the next time the hour will be 7 (either AM or PM). On the case that this is the first time to do ...
2
votes
1answer
138 views

My AJAX LiveDate Object

The LiveDate object displays the live current date and has a sendAjaxRequest() function dependency to send the AJAX requests. ...
6
votes
2answers
89 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
66 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
65 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 ...
4
votes
2answers
43 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
573 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
87 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
549 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
85 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
611 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
61 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
41 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
70 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
68 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
24 views

Complete date ranges for two years

I have array contents with some date ranges, fetched from the database: ...
2
votes
1answer
24 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
113 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
62 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
22 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
62 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
91 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
49 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
646 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
73 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
121 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
41 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 ...